Repository navigation
Description
Summary
When an image has a lazy-load attribute that holds a data: placeholder before its real src, the image parser takes the placeholder as the image's URL. The tag replacer then works on that placeholder instead of the real image, so the image never gets the page profiler's missing-srcset / sizes entries.
<img data-src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" src="https://example.com/wp-content/uploads/2026/10/photo.jpg" alt="Test" />The same image with src first, or without the data-src, is enhanced normally.
Found by the QA agent while testing #1184 / #1185. It also happens on development, so it isn't caused by #1185.
What happens
Optml_Manager::parse_images_from_html()(inc/manager.php) matches the firstsrcorpossible_src_attributes()attribute it finds and returns its value asimg_url. Here that'sdata-src, soimg_urlisdata:image/gif.Optml_Tag_Replacer::process_image_tags()goes ahead with that URL:can_replace_tag( 'data:image/gif' )returnstrue.- The "optimized" URL for
data:image/gifis the placeholder itself, soadd_missing_srcset_attributes()builds every candidate from it.esc_url()turns each one into an empty string, and nothing is added. - The real
srcis still moved to the CDN by the later URL replacement pass. Only the tag-level work is done against the wrong URL.
The image also gets data-opt-id computed from the placeholder URL (get_id_by_url( 'data:image/gif' )) instead of the real image. So every image with that placeholder shares one profiler ID.
Reproduction
PHPUnit, with profiler data seeded for the image (keyed by the real src ID and by the data-opt-id the browser profiler reports, assets/js/modules/srcset-detector.js:139):
| Tag shape | development |
#1185 |
|---|---|---|
data-src="data:…" before src |
not enhanced | not enhanced |
src before data-src="data:…" |
enhanced | enhanced |
no data-src |
enhanced | enhanced |
Impact
- Images whose markup puts a lazy-load
data:placeholder attribute beforesrcmiss the profiler's responsivesrcset/sizes. - Other per-tag work that uses
img_url(crop and dimension handling, profiler IDs, possibly lazy-load decisions) runs against the placeholder. This needs checking.
Possible fix
When picking an image's URL, skip attributes whose value is a data: URI, so a real src is used. This changes what parse_images_from_html() returns, which feeds every image replacement. It needs its own tests across the replacer and lazy-load suites, and a check against possible_src_attributes() integrations.
Activity
kushh23 commentedon Oct 20, 2026
🧪 QA steps and test links
When an image's lazy-load attribute holds a
data:placeholder and comes before the realsrc, Optimole treats the placeholder as the image. Every such image gets the samedata-opt-id, so the page profiler can't give it its own width, height or responsive srcset.Requires: a site connected to Optimole, for the steps outside the links.
data-opt-id="771715633", Image 3 (same file as Image 1) has a different onea9f9857443598161,1527998280), Images 1 and 3 share oneIn the links:
debug.log.Reproduce on Optimole 4.2.17:
data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==<img data-src="PLACEHOLDER" src="URL-A" alt="Image 1"><img data-src="PLACEHOLDER" src="URL-B" alt="Image 2"><img src="URL-A" data-src="PLACEHOLDER" alt="Image 3">data-opt-id.data-opt-id(771715633), although they are different files. Image 3 has another ID, although it is the same file as Image 1.Edge cases
data-srcplaceholder is kept.<img src="PLACEHOLDER" data-lazy-src="URL-A">(another lazy-load plugin owns the image): same output as on 4.2.17, with no extra<noscript>copy.<img data-src="PLACEHOLDER">with nosrc: the page renders normally and the tag is left alone.DATA-SRC="DATA:image/gif...": behaves like Image 1.Fix: #1190 (open)
pirate-bot commentedon Oct 20, 2026
QA agent — 🟢 Passing checks · Placeholder-first images now receive responsive metadata and real-image profiler IDs.
Placeholder-first images now receive srcset, sizes, dimensions, and IDs based on the real photo. The same pages reproduce the missing attributes and shared IDs on the base build. Lazy-load targets and existing third-party noscript structures also behaved as expected, and all four new tests passed on PHP 7.4 and 8.3. This used seeded connection and profile data; live profiler collection and CDN delivery were not verified.
Worth a human look
Checks (5 passed)
Full report, evidence and session trail
Don't take a data: placeholder in a lazy-load attribute as the image …
pirate-bot commentedon Nov 2, 2026
🎉 This issue has been resolved in version 4.2.18 🎉
The release is available on GitHub release
Your semantic-release bot 📦🚀