Image parser uses a data: placeholder from data-src as the image URL, so the real src misses srcset enhancement
メンテナーはふだん 1 日以内に返信
@selul がすでに取り組んでいます。
2026年10月20日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 56/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- PHP
- スター
- 74
- フォーク
- 14
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 21
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Codeinwp/optimole-wp のほかの issue
-
Image URL replacement passes an integer cache token to the Optimole SDK対応中かも @selul が今日担当しました。 オープンbug bug-report bug-report-triage crash-report
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
Codeinwp/optimole-wp#1187 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
customer report feature-request-triage
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
Codeinwp/optimole-wp#1179 ·
メンテナーはふだん 1 日以内に返信
-
customer report feature-request-triage
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
Codeinwp/optimole-wp#1178 ·
メンテナーはふだん 1 日以内に返信
-
bug bug-report bug-report-triage crash-report
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
Codeinwp/optimole-wp#1163 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
customer report feature-request-triage
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
Codeinwp/optimole-wp#1151 ·
メンテナーはふだん 1 日以内に返信
Codeinwp/optimole-wp の issue をすべて見る
似ている issue
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 3 日以内に返信
-
Перевод устарел
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
新版升级一下对应的依赖可以么オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100