Skip to content

Conversation

@AhmedSobhy01
Copy link

This pull request addresses an issue with the TenantAwareUrlGenerator where the URLs in the srcset attribute of responsive images were not tenant-aware, even though the src URL was correctly tenant-aware.

Problem

When fetching the HTML for a media image using the following code:

$item->getFirstMedia('myMediaCollection')?->toHtml()

The generated <img> tag had the correct tenant-aware src attribute, but the srcset attribute URLs were not tenant-aware.

Cause

The issue was traced to the getResponsiveImagesDirectoryUrl method in the DefaultUrlGenerator, which was responsible for generating the URLs for responsive images.

Solution

To fix this, I have overridden the getResponsiveImagesDirectoryUrl method in the TenantAwareUrlGenerator to ensure that the URLs for responsive images are also tenant-aware.

Changes

  • Added: getResponsiveImagesDirectoryUrl method override in TenantAwareUrlGenerator to generate tenant-aware URLs for responsive images.

This change ensures consistency in URL generation for both src and srcset attributes, preventing potential issues where non-tenant-aware URLs might lead to incorrect media being served.


Please review the changes and let me know if you have any concerns. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant