# Load the First Cover Block Image With High Priority

> Marks the background image of the first Cover block on a page with fetchpriority="high" and turns off lazy loading for it, which speeds up hero sections (better LCP).

- Type: PHP
- Runs: Frontend only
- Category: [Block Editor](https://wpide.com/library/category/gutenberg/)
- Tags: performance, cover, images, lcp
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/cover-image-fetchpriority/

## Code

```php
add_filter( 'render_block_core/cover', function ( $content ) {
    static $done = false;

    if ( $done || is_admin() || ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
        return $content;
    }

    $tags = new WP_HTML_Tag_Processor( $content );

    if ( $tags->next_tag( array( 'tag_name' => 'img', 'class_name' => 'wp-block-cover__image-background' ) ) ) {
        $tags->set_attribute( 'fetchpriority', 'high' );
        $tags->remove_attribute( 'loading' );
        $tags->set_attribute( 'decoding', 'async' );
        $done = true;

        return $tags->get_updated_html();
    }

    return $content;
} );
```

## Notes

Only the first Cover block with an image element is changed; later ones keep lazy loading.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Load the First Cover Block Image With High Priority" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
