• I’ve noticed that old posts on my blog that use the ‘wp-block-gallery’ block are no longer properly aligned following recent updates (despite setting the block to center align):

    View post on imgur.com

    However, if I manually edit the post and click publish, the html of ‘wp-block-gallery’ is regenerated with something a bit more modern using flexbox and now fills the container’s width.

    I’d like to find all the posts that use wp-block-gallery blocks and bulk update them to regenerate the html.
    Bulk edit unfortunately does not work, the content remains the same.

    • This topic was modified 2 years, 3 months ago by hedgehog90.
Viewing 2 replies - 1 through 2 (of 2 total)
  • This is not necessary. What you see is a known bug in WordPress 6.1. The core developers had a ticket about it here: https://core.trac.www.ads-software.com/ticket/56970

    Currently, the task to fix it lies with the Gutenberg team: https://github.com/WordPress/gutenberg/issues/45713

    If you want to fix this for your project in the short term and without waiting for 6.1.1, add this to your Additional CSS in the Customizer:

    .is-layout-flex {
    	display: flex;
    }
    Thread Starter hedgehog90

    (@hedgehog90)

    That appears to be a related problem but not the crux of the issue I’ve described.
    When I open one of the old posts in the editor, the front-end gutenberg JS automatically processes the block code to create the latest HTML…

    In the element inspector, the wp-block-gallery tree is essentially figure -> ul -> li, but the latest gutenberg JS converts it to a simpler (better) figure -> figure tree.

    Also I’ve noticed a bug whereby galleries no longer have a bottom margin for some reason.

    Here’s the pre-processed Less I’m using to fix all the issues I’ve mentioned but it’s not ideal:

    // wordpress fixes
    // ---------------------------------------------------
    // undoes a 'fix' applied in 6.0.3
    .wp-block-columns.are-vertically-aligned-center {
    	align-items: center!important;
    }
    // fix after wordpress update
    .wp-block-gallery.aligncenter {
    	justify-content: center;
    }
    // makes old posts using wp-block-gallery like new posts (with new html...)
    .wp-block-gallery {
        margin-bottom: 1rem;
    }
    .wp-block-gallery:not(.has-nested-images) {
        margin-bottom: 1rem;
    	&>ul {
    		flex: 1;
    		gap: inherit;
    		&>li {
    			margin: 0 !important;
    		}
    	}
    }
    • This reply was modified 2 years, 3 months ago by hedgehog90.
    • This reply was modified 2 years, 3 months ago by hedgehog90.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Quick way to bulk re-generate post content following recent editor updates’ is closed to new replies.