If I want to resize uploaded images when named
featureimage.jpg
, whats the best way to do that?
If I want to resize uploaded images when named
featureimage.jpg
, whats the best way to do that?
Well, there’s a plugin that reportedly can resize images on upload. I have no experience with it, though.
However, given the name “featureimage”, it sounds like what you want is to display a resized image for a specific page template. IMO, that is best achieved in the Twig for that page. For instance:
{% set my_image = page.media['featureimage.jpg'] %}
{{ my_image.cropZoom(200, 200).html() }}
See page.media() and the various resize functions.
Yep, that’s exactly what I want to do!
I tried that plugin you mentioned but it can’t discern based on filename.
Your code snippet works a treat!
Thank you
When a contributor uploads an image that is larger than the configured size, Imsanity will automatically scale it down to the configured size and replace the original image. Imsanity also provides a bulk-resize feature to selectively resize previously uploaded images to free up disk space.