wpseek.com
WordPress开发者和主题制作者的搜索引擎



block_core_navigation_set_overlay_image_fetch_priority › WordPress Function

Since7.0.0
已弃用n/a
› block_core_navigation_set_overlay_image_fetch_priority ( $overlay_blocks_html )
参数:
  • (string) $overlay_blocks_html The rendered HTML of the overlay blocks.
    Required: Yes
返回:
  • (string) Modified HTML with fetchpriority="low" on all IMG tags.
定义在:
文档:

Sets fetchpriority="low" on all IMG tags within the navigation overlay.

Images in the overlay are hidden until the menu is opened, so they should not compete with any actual LCP element image on the page.


源码

function block_core_navigation_set_overlay_image_fetch_priority( string $overlay_blocks_html ): string {
	$tags = new WP_HTML_Tag_Processor( $overlay_blocks_html );
	while ( $tags->next_tag( 'IMG' ) ) {
		$tags->set_attribute( 'fetchpriority', 'low' );
	}
	return $tags->get_updated_html();
}