Image size
#198 opened by Res Naegeli
Description
Hi How to prevent the client to upload heavy images (i.e. 11 MB)? Is there a way Ansel can downsize the image when uploading it? Thanks
Replies
- TJ Draper
Replied 4/22/2021 10:05 AM, Edited 4/22/2021 10:16 AM
Ansel cannot/does not prevent the uploading and using of whatever size image the user wants (unless it's under the requirements for the field). However, you should not be outputting that un-optimized image on the front-end of your website. This is kind of the crux of Ansel and the point. The field should define min/max constraints (and you can also use on-the-fly manipulations with the template tags). This removes the need for the user to know or care about image sizes. Ansel stores the original image, then creates an optimized version of the image.
See the following for more details:
https://buzzingpixel.com/software/ansel-ee/documentation/field-type-settings#uploadSaveDirectories
https://buzzingpixel.com/software/ansel-ee/documentation/template-tags#onTheFly
- Res Naegeli
Replied 4/22/2021 10:07 AM, Edited 4/22/2021 10:16 AM
Addition: I found the possibility within EE docs:
If you have defined any image manipulations you can modify the tag with the Short Name of the manipulation. For example, if you’ve defined a “small” manipulation, the following will output the URL to that version: {news_image:small}
When I use this with the Ansel tag adding the short name (:large) no image will be shown
{!-- Output images --} {my_ansel_field:large} {img:url} {/my_ansel_field:large}
What is wrong? Thanks
- TJ Draper
Replied 4/22/2021 10:10 AM, Edited 4/22/2021 10:16 AM
Your code does not match the documentation.
https://buzzingpixel.com/software/ansel-ee/documentation/template-tags#tagPairVarialbes
You would need to do as follows (per the documentation)
{my_ansel_field manipulations="true"} {img:large:url} {/my_ansel_field}
- Res Naegeli
Replied 4/22/2021 10:16 AM
Great, I see... thanks a lot :)