| @@ -376,9 +376,12 @@ | ||
| 376 | 376 | if ( empty( $opts['add_missing_dimensions'] ) ) { |
| 377 | 377 | return; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - if ( ! preg_match_all( '#<img\b[^>]*\bsrc\s*=\s*["\']([^"\']+)["\'][^>]*>#i', $html, $m, PREG_SET_ORDER ) ) { | |
| 380 | + // Match any <img>, not only one carrying `src`. The URL worth warming | |
| 381 | + // may live in a lazy attribute instead — which is the whole point of | |
| 382 | + // #328 — and resolvable_image_url() below is what knows where to look. | |
| 383 | + if ( ! preg_match_all( '#<img\b[^>]*>#i', $html, $m, PREG_SET_ORDER ) ) { | |
| 381 | 384 | return; |
| 382 | 385 | } |
| 383 | 386 | |
| 384 | 387 | $home = wp_parse_url( home_url(), PHP_URL_HOST ); |
| @@ -385,13 +388,30 @@ | ||
| 385 | 388 | $targets = array(); |
| 386 | 389 | foreach ( $m as $tag ) { |
| 387 | 390 | // Only tags MISSING a dimension are worth resolving — one that |
| 388 | 391 | // already declares both needs nothing. |
| 389 | - if ( preg_match( '#\bwidth\s*=#i', $tag[0] ) && preg_match( '#\bheight\s*=#i', $tag[0] ) ) { | |
| 392 | + // Same lookbehind as Lazy_Loader::ensure_dimensions(): a bare | |
| 393 | + // `\bwidth=` also matches `data-width=`, so a slider carrying its | |
| 394 | + // own metadata looked already-sized and was skipped from warming. | |
| 395 | + // The two must agree, or the collector skips exactly the tags the | |
| 396 | + // renderer still needs measured. (#333 review round 3, issue 2) | |
| 397 | + if ( preg_match( '#(?<![-\w])width\s*=#i', $tag[0] ) && preg_match( '#(?<![-\w])height\s*=#i', $tag[0] ) ) { | |
| 390 | 398 | continue; |
| 391 | 399 | } |
| 392 | - $src = $tag[1]; | |
| 393 | - if ( ! preg_match( '#^https?://#i', $src ) ) { | |
| 400 | + // Ask the same resolver the render path uses, rather than reading | |
| 401 | + // `src` directly. A slider parks a spacer in `src` and the real | |
| 402 | + // URL in `data-lazy`/`data-src`/`data-original`, so a collector | |
| 403 | + // looking only at `src` warmed the SPACER and never the image — | |
| 404 | + // leaving remotely-hosted slider images unresolvable at render | |
| 405 | + // time, the exact markup #328 is about. (#333 review round 2, | |
| 406 | + // issue 3) | |
| 407 | + // `false`: do not let the resolver settle a name-refused URL by | |
| 408 | + // MEASURING it. That is circular here — remote measurement is | |
| 409 | + // gated until warm_dimensions() sets $warming, and this collector | |
| 410 | + // is what feeds warm_dimensions(). Take the URL the tag offers and | |
| 411 | + // let the warm pass decide. (#333 review round 3, issue 3) | |
| 412 | + $src = Lazy_Loader::resolvable_image_url( $tag[0], false ); | |
| 413 | + if ( '' === $src || ! preg_match( '#^https?://#i', $src ) ) { | |
| 394 | 414 | continue; |
| 395 | 415 | } |
| 396 | 416 | $host = wp_parse_url( $src, PHP_URL_HOST ); |
| 397 | 417 | if ( ! $host || $host === $home ) { |