Opened 6 weeks ago
Last modified 6 weeks ago
#64554 new enhancement
New src_matched value filter request
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | blocker | Version: | 6.9 |
| Component: | Media | Keywords: | needs-patch |
| Focuses: | Cc: |
Description
Hi,
I am uploading media to Amazon S3 and serving media URLs directly from S3. All media URLs are successfully replaced and served from S3 without issues.
However, when I enable object versioning in S3, WordPress fails to generate srcset. Specifically, the URL becomes something like:
https://.../any/uploads/2026/01/8728723/a.jpg
This happens because wp_calculate_image_srcset() receives the S3 URL as $image_src, since the URL is already replaced via a the_content filter. Due to this, the internal src_matched check fails, and the function simply returns false.
As a result, no srcset is generated.
I need a filter or hook inside wp_calculate_image_srcset() to detect whether the provided image URL is an S3 URL. If it is, I need a way to force the src_matched check to return true.
I have already tested this by modifying wp_calculate_image_srcset() directly, and it successfully generates image sizes using the S3 URLs. However, modifying core is not a viable solution, so I am looking for a proper filter-based approach.
Any guidance or suggestions would be appreciated.
Thank you.
I’d like to work on this and will submit a patch soon.