Skip to content

Commit f7f3da5

Browse files
committed
Fix WP 6.7 chrome problem with lazy loading
1 parent 495047c commit f7f3da5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

functions.php

+20
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,24 @@ function disable_emojis() {
393393
}
394394
add_action('init', 'disable_emojis');
395395

396+
397+
/**
398+
* Disable Chromium feature that applies `contain-intrinsic-size` to images with
399+
* `sizes="auto"` attribute. This prevents unexpected layout shifts caused by
400+
* missing `width` and `height` attributes.
401+
*
402+
* WordPress 6.7 introduced a feature that automatically adds `loading="lazy"`
403+
* to images without validating the presence of these attributes. This behavior
404+
* can cause rendering issues, especially in Chromium-based browsers, due to
405+
* their CSS adjustments for such images.
406+
*
407+
* Applying this filter disables the `auto-sizes` feature in WordPress until
408+
* a permanent patch is released (scheduled for version 6.7.1).
409+
*
410+
* @link https://core.trac.wordpress.org/ticket/62413
411+
* @link https://ericportis.com/posts/2023/auto-sizes-pretty-much-requires-width-and-height/
412+
* @author Petr Kucera
413+
*/
414+
add_filter('wp_img_tag_add_auto_sizes', '__return_false');
415+
396416
?>

0 commit comments

Comments
 (0)