Custom image sizes overwritten with original
-
I have just been debugging an issue with this plugin and Elementor.
When an image widget is set to use a registered custom image size (eg I have one named ‘1200×900’), the front-end <img> tag has the custom image size URL replaced with the original image URL in the src attribute.
The custom size still appears in the srcset, but it’s removed from the src by PostContentImageTagObserver::run
This replaces the incoming image URL using wp_get_attachment_url(), which always returns the full image URL.
Expected output:
<img loading="lazy" decoding="async" width="1200" height="900" src="https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1-1200x900.jpg" class="attachment-1200x900 size-1200x900 wp-image-36231" alt="" srcset="https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1-1200x900.jpg 1200w, https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1-600x450.jpg 600w, https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1-800x600.jpg 800w" sizes="(max-width: 1200px) 100vw, 1200px">
Actual output:<img loading="lazy" decoding="async" width="1200" height="900" src="https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1.jpg" class="attachment-1200x900 size-1200x900 wp-image-36231" alt="" srcset="https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1.jpg 1200w, https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1-600x450.jpg 600w, https://cdn.mysite.example/wp-content/uploads/2026/02/test-new-2-1-800x600.jpg 800w" sizes="(max-width: 1200px) 100vw, 1200px">The incoming $filtered_image URL is already correct, so perhaps it needs a check to see whether this is already on the offloaded domain before doing the replacement?
You must be logged in to reply to this topic.