0

How to run this filter only on some specific registered thumbnail sizes '$size' ? like 'large' , 'medium' ....

add_filter( 'wp_get_attachment_image_attributes', 'wpse8170_add_lazyload_to_attachment_image', 10, 2 );
function wpse8170_add_lazyload_to_attachment_image( $attr, $attachment ) {
$attr['data-original'] = $attr['src'];
$attr['src'] = 'grey.gif';
return $attr;
}

Thanks

1 Answer 1

1

This is a hack, but I guess it should work...

add_filter( 'wp_get_attachment_image_attributes', 'wpse8170_add_lazyload_to_attachment_image', 10, 2 );
function wpse8170_add_lazyload_to_attachment_image( $attr, $attachment ) {
    //use your image size here with attachment
    if($attr['class'] == 'attachment-large'){
        //do your stuff
    }
    return $attr;
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.