Site logo

Archived topic

Maintain width / height of image?

4 replies · Started by Jack on September 25, 2021

Viewing posts 1–5 of 5

Hey guys,

Is it possible, when using image blocks in containers, to maintain the width / height of an image, no matter what size image you choose? So, for example, you have three 600 x 600 images side by side, but you want to quickly replace one of the images with a 800 x 900 image.. can you automatically 'crop' or 'contain' that image to fit and be 600 x 600 like the rest?

Hi there,

2 options:

1. Is to use CSS to force the images to display at that size, which would treat them like a background image. If i can see the site i can provide some CSS for that.

2. Create a new image size that is 600 x 600 cropped, that can then be selected in the Image Block - see here:

https://docs.generatepress.com/article/adding-image-sizes/

Option 2 would make the most sense.

Hey David,

Thank you for the prompt response.

I like the sound of option 2. I've added the function into my Code Snippets plugin, but it's not showing up as an option on the image block settings? I still only see 'Thumbnail; Small; Medium; Large & Full Size'.

Just to add, I notice the the article on functions you sent is categorised as a 'blog' function, but I wish to use this on normal pages image blocks too. Is this possible?

Ah that doc is a little misleading - we reference the Blog module as its the only place in GPP where you can set an image size. But adding that function ( and running the Regenerate Thumbnails plugin ) will create new image sizes that can be used for any image on the site... not just in the GPP blog settings.

This archived topic is closed to new replies.