Responsive images are being loaded with cached redirect domains in certain cases

Created on 10 August 2022, almost 2 years ago
Updated 27 January 2023, over 1 year ago

Problem/Motivation

URLs to image files are cached including the domain. In a multidomain environment, this causes unnecessary redirects, that can also fail if SSL is enabled on one domain and not the other.

Proposed resolution

The Problem could probably be resolved by serving the picture source sets as root-relative paths (e.g. /some/path/image.png) instead of absolute URLs (e.g. https://cached-domain.com/some/path/image.png). The source of the problem is located in the pagedesigner_responsive_images module, where the twig extension function styled_image_url() which is being called from the responsive-image.html.twig in the iq_barrio theme returns a absolute URL in the getStyledImageUrl() function in ResponsiveImageStylesTwigExtension.php.

There is a core issue on the topic of ImageStyle::buildUrl() returning absolute URLs instead of root-relative paths here. And in there is also a solution: you could call file_url_transform_relative() on the absolute URL before returning (will be deprecated in D10, see here).

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡­Switzerland pvbergen

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.69.0 2024