Repository navigation
Commit a8a343d
committed
Script Loader: Ignore image preloads that have no URL.
An image resource passed through the `wp_preload_resources` filter without an `href` was accepted when it had either `imagesrcset` or `imagesizes`, but `imagesrcset` was always used as the key for removing duplicates. A resource with only `imagesizes` therefore raised an undefined array key warning (plus a null array offset deprecation on PHP 8.5), collapsed every such resource onto the same empty key, and printed a `<link>` with no URL at all, since `imagesizes` is only output alongside `imagesrcset`. A resource with neither `href` nor `as` raised a warning as well.
Such a resource is now skipped unless `as` is `image` and `imagesrcset` is set. PHPStan reports the missing offsets once the filter's value is typed from its documented hash notation.
Developed in #15380.
Follow-up to r53846.
Props westonruter, adamsilverstein.
See #65817.
git-svn-id: https://develop.svn.wordpress.org/trunk@65215 602fd350-edb4-49c9-b593-d223f7449a821 parent fe84ed8 commit a8a343d
2 files changed
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4107 | 4107 | | |
4108 | 4108 | | |
4109 | 4109 | | |
4110 | | - | |
4111 | | - | |
4112 | | - | |
| 4110 | + | |
4113 | 4111 | | |
4114 | 4112 | | |
4115 | 4113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
260 | 287 | | |
261 | 288 | | |
262 | 289 | | |
0 commit comments