Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To disable WordPress core’s lazy-loading attribute across a site, add this filter in a site-specific plugin or child theme:

add_filter( 'wp_lazy_loading_enabled', '__return_false' );

Use a scoped rule instead when only a hero image, logo, or another above-the-fold image needs eager loading. That preserves lazy loading for images that remain below the fold.

Choose the smallest scope that solves the problem

Need WordPress mechanism Scope
Remove core lazy-loading attributes broadly wp_lazy_loading_enabled returning false All supported tags and contexts affected by the callback
Disable it only for a tag or context A callback that checks $tag_name and $context Selected core output paths
Omit the attribute on selected content images wp_img_tag_add_loading_attr filter Matching images in its supported content path; review version status
Omit it on one generated attachment image Pass 'loading' => false to wp_get_attachment_image() That generated image

The global filter is the direct choice when the requirement is literally “disable WordPress core lazy loading everywhere.” A selective rule is safer when the concern is limited to one image or template.

Disable WordPress core lazy loading site-wide

Place the filter in a site-specific plugin or a child theme’s functions file so a parent-theme update does not remove it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
wordpress hosting
  • easy to use
  • Free app
  • Compatible with all devices
  • It gives the best comparison between ten different hosts
add_filter( 'wp_lazy_loading_enabled', '__return_false' );

wp_lazy_loading_enabled was introduced in WordPress 5.5.0. The callback receives the default boolean, the tag name, and the context, allowing the same hook to make a narrower decision.

Disable it only for a tag or context

Return false only for the markup path that needs changing. For example, this leaves other core contexts unchanged while disabling the attribute for images generated in a selected context:

function my_disable_lazy_loading selectively( $default, $tag_name, $context ) {
    if ( 'img' === $tag_name && 'my_context' === $context ) {
        return false;
    }

    return $default;
}
add_filter( 'wp_lazy_loading_enabled', 'my_disable_lazy_loading selectively', 10, 3 );

Replace my_context with the actual context used by your theme or code. Do not assume a context name without checking the code that emits the image. Because this callback is context-aware, it can target a tag or context rather than turning off the feature globally.

Omit lazy loading for one generated attachment image

When your template uses wp_get_attachment_image(), pass a false loading attribute in the image attributes:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
echo wp_get_attachment_image(
    $attachment_id,
    'large',
    false,
    array( 'loading' => false )
);

This asks WordPress to omit the loading attribute for that generated image. It is appropriate for a known hero image or another specific attachment, while leaving other images unchanged.

Handle content images carefully across WordPress versions

Older examples commonly use the wp_img_tag_add_loading_attr filter for images in processed content. Returning false (or an empty string) prevents the attribute from being added when that filter applies:

function my_skip_lazy_loading_for_match( $value, $image, $context ) {
    if ( false !== strpos( $image, 'class="hero-image"' ) ) {
        return false;
    }

    return $value;
}
add_filter( 'wp_img_tag_add_loading_attr', 'my_skip_lazy_loading_for_match', 10, 3 );

Check the installed WordPress release before adopting this pattern. The wp_img_tag_add_loading_attr() function reference is marked deprecated since WordPress 6.3.0, and WordPress’s newer optimization-attributes API is the current implementation direction. A snippet written for an older release may not be the best path on a current site.

Where WordPress core may add the attribute

Core documentation identifies several relevant output paths:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Post content through the_content
  • Excerpts through the_excerpt
  • Text widgets through widget_text_content
  • Avatars through get_avatar
  • Template images created with wp_get_attachment_image()

Core also applies viewport-sensitive optimization behavior, so the exact attributes on a page can depend on an image’s position and context. A rule that changes one output path will not necessarily affect images emitted by another.

Verify the rendered result

  1. Apply the filter in the site-specific plugin or child theme.
  2. Clear page-cache, optimization-plugin, and CDN caches.
  3. Open the affected page and inspect its final HTML, not only the editor markup.
  4. Search the relevant <img> elements for loading="lazy".
  5. If the attribute remains, identify which component generated that element and test that path separately.

A theme, image-optimization plugin, CDN, or custom script can add its own lazy-loading behavior. WordPress core filters do not automatically override those systems. If the image is still lazy-loaded after the core attribute is gone, inspect the element for plugin-specific attributes, JavaScript classes, or script-driven loading.

Do not use loading="eager" as a blanket workaround

WordPress recommends omitting the loading attribute by returning false when you want to disable lazy loading for an image. Setting loading="eager" merely to countermand lazy loading is a different instruction and can create unnecessary eager requests for images that are not immediately visible.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failure modes

The global snippet has no visible effect

  • The code is not loading because it was placed in a file that is not active.
  • A full-page or CDN cache is serving old HTML.
  • A plugin or theme adds its own lazy-loading system after WordPress core runs.

Only some images changed

The remaining images may come from a different context, such as a widget, avatar, content filter, or custom template. Trace the markup path and apply a scoped rule to that path instead of adding unrelated global code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
WordPress Hosting Guide
  • Free WordPress Hosting Guide Android Application. It Contains: A Brief Overview of WordPress Hosting, 9 Major Benefits of Managed WordPress Hosting.
  • 5 Simple Steps to Choose WordPress Hosting, How to Maximize Your WordPress Hosting and Blogging Success, How to Choose the Best WordPress Hosting Provider, Optimize Your Blog with VIP Word.
  • Press Hosting, What You Should Know to Choose the Best WordPress Hosting and Much More.

An old per-image snippet causes warnings

Review the installed WordPress version. Code based on the deprecated wp_img_tag_add_loading_attr() path should be replaced or adapted to the current optimization-attributes API where appropriate.

Recommended implementation pattern

Start with the narrowest change that meets the requirement:

Quick Recap

Bestseller No. 1
wordpress hosting
wordpress hosting
easy to use; Free app; Compatible with all devices; It gives the best comparison between ten different hosts
Bestseller No. 5
WordPress Hosting Guide
WordPress Hosting Guide
Press Hosting, What You Should Know to Choose the Best WordPress Hosting and Much More.
  1. For one known attachment, pass 'loading' => false to wp_get_attachment_image().
  2. For a defined tag or output context, return false conditionally from wp_lazy_loading_enabled.
  3. Use the unconditional __return_false callback only when every core-supported context should omit the attribute.
  4. Inspect final HTML and test pages that use each affected output path.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.