Site logo

Archived topic

Gallery Problems After Updating To WP 5.9

14 replies · Started by Patrick on January 27, 2022

Viewing posts 1–15 of 15

I have an image gallery in all of my posts with images set to not cropped, thumbnail size, 3 or 4 columns.

If I look at an old post (anything before the WP 5.9 upgrade this week), the gallery images look fine. If I go into that old post and click Update (without changing anything in the post), the gallery images change to stretched in safari and full-size singe column (instead of 3 or 4 columns) in chrome and firefox.

Also, newly created posts are having the same issue since WP 5.9 upgrade.

I have tried deleting gallery and re-adding, same issue. All caches cleared.

See attached example urls.

Hi Patrick,

Upon inspecting both the Image Gallery blocks in the links you sent, it seems that the two aren’t set up the same.

Specifically, one gallery has a CSS class of column-4 and the other has a CSS class of column-default.

Kindly see: https://share.getcloudapp.com/6quEZnWJ

Also see: https://share.getcloudapp.com/4guZKEbW

With that said, can you check if they indeed have the same exact settings?

GeneratePress and WordPress don’t usually change HTML structure like classes or IDs.

Hope to hear from you soon. Thank you! :)

They are set up exactly the same, column 4. Something is being changed if I save a post after updating to WP 5.9. If I edit the post that looks fine now and then save it, its gallery will get screwed up too.

David … can you take a look at this for me?

Hi there,

looks like WP decided to completely revise the HTML for the Block Gallery and to completely forgo adding their own Grid CSS.
Can you try adding this:

.wp-block-gallery {
    display: flex;
    flex-wrap: wrap;
}

We'll take a look into what WP have done here

Thanks, I figured they did something wonky like that.

I added your code to additional CSS. Unfortunately, nothing changed and the problem still persists.

Any cache plugins or server side caches in place?
If so can you try clearing them.

Yes, was just checking that ... sorry ;-) After clearing cache, columns issue is resolved, but images still stretched in safari and full-sized in chrome and firefox. They are supposed to be thumbnail-sized.

Hi Patrick,

I compared the 2 galleries, I don't see any GP CSS is messing with the layout.

But I do see a lot of changes made by WP. If you switch the theme to Twenty twenty series, are the images still stretched?

Let me know :)

Yes, Ying … I switched to Twenty Twenty Two and had same issue. Still, it only occurs if I update a post or create a new one.

It looks like WP 5.9 updated its gallery block into this new way.

I'm afraid it will be like this from now on.

As it's a WP core block, we are not able to control its behavior Unfortuanly.

I just rolled back WP to 5.8.3. The two pages at issue have corrupted galleries now that will need to be recreated. However, the rest of the site has no problems.

Apparently, 5.9 is actually changing the way it handles individual post galleries. Not sure how to proceed as this is going to affect a lot of people ... you can't just not have galleries now.

Yea, I'm sure WP will receive a lot of feedbacks on this.

Temporary work-around for others having the same issue:

I have added the following code which resolves the only one column issue on chrome or firefox:

.wp-block-gallery {
    display: flex;
    flex-wrap: wrap;
}

It appears that the "stretching" images issue is from 5.9 trying to full justify the gallery block, even if you set justification to none, center, etc. Flipping on the crop images button seems to revolve the issue, but I am still limited to large size images, not thumbnails. Anyway, it is a work-around.

Thanks for sharing Patrick :)

This archived topic is closed to new replies.