Image parser uses a data: placeholder from data-src as the image URL, so the real src misses srcset enhancement
I maintainer di solito rispondono entro 1 giorno
@selul ci sta già lavorando.
Dal 20/10/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 56/100
Direzione di ricerca
Start with Optml_Manager::parse_images_from_html() in inc/manager.php and trace how its selected URL reaches Optml_Tag_Replacer::process_image_tags() and add_missing_srcset_attributes(). Reproduce the two attribute orders from the issue in PHPUnit, using profiler data keyed to the real src and reported data-opt-id; check the replacer and lazy-load suites plus integrations using possible_src_attributes(). Done when the real image URL drives per-tag processing and the data: placeholder order receives the expected srcset and sizes.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 74
- Fork
- 14
- Merge medio
- 2g 9h
- PR unite (30g)
- 22
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Codeinwp/optimole-wp
-
Image URL replacement passes an integer cache token to the Optimole SDKForse già presa @selul l’ha presa 1 giorno fa. Apertabug bug-report bug-report-triage crash-report
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Codeinwp/optimole-wp#1187 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
customer report feature-request-triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Codeinwp/optimole-wp#1179 ·
I maintainer di solito rispondono entro 1 giorno
-
Add setting to disable Optimole URL rewriting for social meta tags (og:image / twitter:image)Apertacustomer report feature-request-triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
Codeinwp/optimole-wp#1178 ·
I maintainer di solito rispondono entro 1 giorno
-
bug bug-report bug-report-triage crash-report
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Codeinwp/optimole-wp#1163 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
customer report feature-request-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
Codeinwp/optimole-wp#1151 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Codeinwp/optimole-wp
Issue simili
-
0.kind: enhancement 9.needs: package (update)
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
NixOS/nixpkgs#577156 · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
tine-groupware/tine#277 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
MagnaCapax/PMSS#1142 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Native-arrow select renders a second Jetpack chevronForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Automattic/static-site-importer#2294 ·
I maintainer di solito rispondono entro 1 giorno
-
bug 🐛
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
netalertx/NetAlertX#1856 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno