Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Created March 17, 2022 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/eb33aa3de635a5716650c59757ee9232 to your computer and use it in GitHub Desktop.
Save zackkatz/eb33aa3de635a5716650c59757ee9232 to your computer and use it in GitHub Desktop.
GravityView - Disable lazy loading for images
<?php
/**
* Disable lazy loading for images in GravityView (added in 2.14.3).
*
* @param string|bool $value The `loading` attribute value. Returning a falsey value will result in
* the attribute being omitted for the image.
* @param string $image The HTML `img` tag to be filtered.
* @param string $context Additional context about how the function was called or where the img tag is.
*/
*/
add_filter( 'wp_img_tag_add_loading_attr', function ( $value, $image, $context ) {
// This is not a GravityView image; don't modify lazy loading behavior.
if ( 'gravityview-image' !== $context ) {
return $value;
}
return false;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment