Site logo

Archived topic

Gallery Block crop not working

3 replies · Started by Reed on April 7, 2022

Viewing posts 1–4 of 4

I have a gallery block in one of my posts. As I have photos in landscape and portait mode, I want to use the cropping feature to have a cleaner look. While editing the post, the gallery looks fine. In preview mode or when published, the images are NOT cropped. See examples on this post: https://frugalflyer.ca/blog/5-things-to-see-and-do-in-anchorage-alaska/

Has anyone an idea why this is not working? Could it be a theme issue?

Hi there,

you're site is running an image optimizer, which is swapping <img> HTML for <picture> HTML and that core Gallery block only applies its styles to the <img> - try adding this CSS to make it work for <picture> elements too:

.wp-block-gallery.has-nested-images.is-cropped figure.wp-block-image:not(#individual-image) picture {
    width: 100%;
    flex: 1 0 0%;
    height: 100%;
    -o-object-fit: cover;
    object-fit: cover;
}

Worked! Thanks :)

Glad to hear that!

This archived topic is closed to new replies.