Created
November 20, 2024 22:45
-
-
Save conorseed/56441257d029ed4e248542859536ab13 to your computer and use it in GitHub Desktop.
Themeco Cornerstone / Pro Theme - Disable Image Lazy Load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Disable lazy loading for Cornerstone image elements | |
* ===== 1. Add this code to functions.php in your child theme | |
* ===== (see here: https://theme.co/docs/child-themes) | |
* ===== 2. Add 'x-no-lazy' class to any image element | |
* ===== OR to any parent element and all image elements within the parent | |
* ===== (including background image elements) will no longer be lazy loaded | |
*/ | |
add_filter('cs_tag_content', function ($content, $atts) { | |
if (isset($atts['class']) && is_array($atts['class']) && in_array('x-no-lazy', $atts['class'])) { | |
$content = str_replace('loading="lazy"', 'loading="eager"', $content); | |
} | |
return $content; | |
}, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment