Support responsive images

Created on 9 November 2017, over 7 years ago
Updated 2 September 2024, 8 months ago

Drupal 8 core has a theme function used for outputting responsive images. When the markup for the responsive image is generated, it needs the width of the image. If the image doesn't exist, it throws an exception and breaks the entire page. See πŸ› Exception thrown by responsive srcset images when the image is not yet in the file system (such as with Stage File Proxy) Needs work for more details.

I'm not sure this is a problem that can be solved in core. To Drupal, it's reasonable to expect that the image you're trying to render actually exists.

Instead, I think this module can intervene. How about adding a template preprocessor for the responsive image theme function that executes BEFORE core's preprocessor (which is where it checks for the image width). SFP can download the image attempting to be rendered if it doesn't already exist.

One big difference is that the main Drupal page request would be the request that's downloading the external file, whereas normally SFP does its thing when a user's browser makes individual requests for the images. Could that cause problems? I don't think so.

Looks like the code to actually fetch the image is already completely abstracted to its own service class, which is great and should make this easier.

✨ Feature request
Status

Postponed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024