Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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;
}
share|improve this answer
    
it works, thanks –  NecroMido Jun 20 '12 at 11:34
    
Ohh cool! You're welcome! :D –  Rutwick Gangurde Jun 20 '12 at 12:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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