diff --git a/backport-changelog/7.0/11196.md b/backport-changelog/7.0/11196.md new file mode 100644 index 00000000000000..2c53419b6785f0 --- /dev/null +++ b/backport-changelog/7.0/11196.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/11196 + +* https://github.com/WordPress/gutenberg/pull/76302 diff --git a/lib/block-supports/block-visibility.php b/lib/block-supports/block-visibility.php index dd3e214fd08ca8..6bbce6b15cfb15 100644 --- a/lib/block-supports/block-visibility.php +++ b/lib/block-supports/block-visibility.php @@ -137,6 +137,16 @@ function gutenberg_render_block_visibility_support( $block_content, $block ) { $processor = new WP_HTML_Tag_Processor( $block_content ); if ( $processor->next_tag() ) { $processor->add_class( implode( ' ', $class_names ) ); + + /* + * Set all IMG tags to be `fetchpriority=auto` so that wp_get_loading_optimization_attributes() won't add + * `fetchpriority=high` or increment the media count to affect whether subsequent IMG tags get `loading=lazy`. + */ + do { + if ( 'IMG' === $processor->get_tag() ) { + $processor->set_attribute( 'fetchpriority', 'auto' ); + } + } while ( $processor->next_tag() ); $block_content = $processor->get_updated_html(); } }