If I want to resize uploaded images when named
featureimage.jpg, whats the best way to do that?
Community guidelines
Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.
Solved by Oliver Scholz View solution
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.
Log in to reply.
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 2 | 53 | 9 hours ago | ||
| 2 | 59 | 12 hours ago | ||
| 1 | 30 | 13 hours ago | ||
| 2 | 65 | 5 days ago | ||
| 2 | 56 | 5 days ago |