Skip to content

Instantly share code, notes, and snippets.

@conorseed
Created November 20, 2024 22:45
Show Gist options
  • Save conorseed/56441257d029ed4e248542859536ab13 to your computer and use it in GitHub Desktop.
Save conorseed/56441257d029ed4e248542859536ab13 to your computer and use it in GitHub Desktop.
Themeco Cornerstone / Pro Theme - Disable Image Lazy Load
<?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