Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Resize thumb while respecting the ratio of the image

Started by Muut Archive 9 years ago · 2 replies · 366 views
9 years ago

Hi there!
I am working on a photography portfolio website. Because the original images will be quite big in filesize, I'd like to display thimbs on the portfolio overview. I use masonry to layout the images. Now I would like to resize the image/thumb in such a way that only the width is set and that the height will change accordingly to the original width-height ratio. Is there a way to do this? I tried doing this by adding a wildcard to the resize method: {{ image.cropResize(480,*).url }}, but unfortunately this did not work. Is there another way to do it?

Cheers!
Ernest

9 years ago

It was. In essence: image.cropResize defines a bound-box, ie. max-sizes, not exact sizes. Thus the image's ratio is maintained, and for a landscape-image the width-property (the first) takes precedence as long as there is room in the height-property.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1333 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2935 9 years ago
Archive · by Muut Archive, 9 years ago
3 1110 9 years ago