question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support disabling/limiting use of image renditions

See original GitHub issue

It would be useful to be able to disable or reduce the usage of image renditions, at least for certain images.

Some images (mainly large animated GIFs) can cause problems with Willow/Wand and fail the rendition step. This is not a Wagtail issue per se, but there’s no way to avoid invoking those libraries even if you only need the original-sized image that you uploaded. Without #929, there’s no way to decouple revisions from Wagtail page loads (for example generating them offline using a different library).

The rendition process also invokes Willow to open and then re-save images even if you only ever want to display the 'original' rendition. This can be suboptimal if, say, users want to explicitly prevent any kind of recompression from occurring to uploaded files.

It would be nice to be able to configure Wagtail to always link to the original image when an original or resize-only operation is requested (DoNothingOperation, MinMaxOperation, or WidthHeightOperation). The {% image %} template tag could still generate the appropriate width and height parameters in the <img> tag, so that images would display at desired sizes (for example as thumbnails on the image browse page).

Here’s a workaround that uses a custom image model that overrides get_rendition to skip renditions for all GIFs (here it is as a PR to give a little more context). This required a few hacks, for example because image operations don’t easily expose their resizing logic independently from actually applying it.

If there’s interest in a feature like this, I’d be happy to submit a PR. One detail to discuss would be level of configurability, i.e. site-wide via setting vs. per-image type vs. per-image (maybe a “disable renditions” checkbox in the admin upload).

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tomdysoncommented, Feb 8, 2017

@chosak are you still interested in submitting a PR for this? We would welcome your help.

1reaction
gasmancommented, Dec 9, 2016

You’ve touched on it, but I think it’s worth pointing out that passing images through Willow, even with the ‘original’ filter, is not universally a bad thing - it can potentially apply optimisations, reduce JPEG quality settings to the global default, and strip EXIF metadata, which are all important if you’re chasing Google PageSpeed scores… having distinct ‘original’ and ‘raw’ filter types may well be the answer to that.

It strikes me that there are a couple of other strands of work potentially related to this:

  • #1708 (support for SVG images): similar to this in that it’s an image type that needs to bypass the whole ‘renditions’ paradigm
  • Not currently a ticket, but something that’s been discussed in chat: the ability to set size constraints on a selected image (e.g.: the photo on a PersonPage must be at least 400x300). This is a tricky thing to approach, since it risks tying page content too closely to a given page design.

For the latter, we considered introducing a concept of distinct “image types”, which would be defined either in the settings file or at a per-app level (possibly in models.py or wagtail_hooks) - ImageChooserPanel and ImageChooserBlock would then allow limiting the available images to one type. Possible business rules to be specified through image types might include, for example:

  • Partner logo: must be a PNG sized at least 300x150, or SVG
  • Staff photo: must be a JPG sized at least 400x400; user will be prompted to select a square crop of the image on upload; we will pre-generate 400x400 and greyscale 200x200 renditions of the image
  • Hero image: Any format, must be exactly 1000x400; templates may only use this with the ‘raw’ image filter to prevent recompression
  • Animation: must be in GIF format, any size; templates may only use this with the ‘raw’ image filter to prevent recompression
Read more comments on GitHub >

github_iconTop Results From Across the Web

AEM Image Processing and Best Practices
Rendition is a process of creating multiple sizes and versions of images post uploading them to DAM (Digital Asset Management). These renditions ......
Read more >
SharePoint Design Manager image renditions | Microsoft Learn
An image rendition defines the dimensions that are used to display images in SharePoint publishing sites. Image renditions enable you to display ...
Read more >
AEMCaas - How to handle caching for renditions for images?
in AEM CS I advise not to use the AdaptiveImageServlet of ACS AEM Commons, ... Use image profiles and let the AssetCompute service...
Read more >
Manage Image Renditions - Oracle Help Center
You can upload custom renditions of your images to suit the channel they're published to (mobile, tablet, web, etc.).
Read more >
Image renditions
Image rendition ensures you get the perfect image used. When you upload a new image to a SharePoint environment using renditions, such as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found