Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Responsive Image URLs in TenantAwareUrlGenerator to be Tenant-Aware #279

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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