Recommended Free Tools
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:
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- 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.
Rank #2
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.
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:
- 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.
Rank #4
Verify the rendered result
- Apply the filter in the site-specific plugin or child theme.
- Clear page-cache, optimization-plugin, and CDN caches.
- Open the affected page and inspect its final HTML, not only the editor markup.
- Search the relevant
<img>elements forloading="lazy". - 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.
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.
Best Value
- 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
- For one known attachment, pass
'loading' => falsetowp_get_attachment_image(). - For a defined tag or output context, return
falseconditionally fromwp_lazy_loading_enabled. - Use the unconditional
__return_falsecallback only when every core-supported context should omit the attribute. - 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.

