Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Image parser uses a data: placeholder from data-src as the image URL, so the real src misses srcset enhancement

Abierto
#1,186 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@selul ya está trabajando en esto.

Desde el 20/10/2026.

  • #1195 de @pirate-bot — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
56/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, wordpress
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug bug-report

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

  1. Optml_Manager::parse_images_from_html() (inc/manager.php) matches the first src or possible_src_attributes() attribute it finds and returns its value as img_url. Here that's data-src, so img_url is data:image/gif.
  2. Optml_Tag_Replacer::process_image_tags() goes ahead with that URL: can_replace_tag( 'data:image/gif' ) returns true.
  3. The "optimized" URL for data:image/gif is the placeholder itself, so add_missing_srcset_attributes() builds every candidate from it. esc_url() turns each one into an empty string, and nothing is added.
  4. The real src is 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 before src miss the profiler's responsive srcset / 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.

Lenguaje dominante
PHP
Estrellas
74
Forks
14
Merge medio
2 d 9 h
PR fusionados (30 d)
22

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Codeinwp/optimole-wp

Todos los issues de Codeinwp/optimole-wp

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.