Follow-up to #2260061: Responsive image module does not support sizes/picture polyfill 2.2
- Adjusts theme('responsive_image') to require the caller to provide a 'width' and 'height', like theme('image_style') does. The 95% use case caller (the image field formatter) passes the dimensions anyway (the Imageitem has them).
This improves consistency bewteen responsive and non-responsive styles.
- Improves perf by removing the code that repeatedly reads the dimensions from the file. We stopped doing that in D7 (IIRC) for image styles for performance (reading dimensions on each output can be nastly if the file is not local ?)
Also, removes the need to create an ImageInterface object for the file altogether.
- As a side effect, strramlines a bit the logic between template_preprocess_responsive_image_formatter() responsive_image_build_source_attributes() and how they work together.
- Adjusts the phpdoc for responsive_image_build_source_attributes() accordingly, and fixes a couple nits while we're in there :-)
Beta phase evaluation
Issue category | Task: Improve performance and consistency of the theme function responsive images |
---|---|
Issue priority | Not critical (but the perf impact for repeatedly reading dimensions from non-local files might be noticeable ?) |
Prioritized changes | The main goal of this issue is performance (and streamlining some code) |
Disruption | Disruptive for contributed modules that call theme('responsive_image') directly, they now need to pass the explicit 'width' and 'height' of the image - should be pretty limited, the main entry point for this is Core's ResponsiveImageFormatter |
Original report by [username]
I think we can still streamline responsive_image_build_source_attributes() a bit, but this can totally happen in a followup.
This needs a bit more information ;-)