Created
April 2, 2016 11:26
-
-
Save stebrech/f605c3a70d4ee8dc0f362f9fccc6a5f7 to your computer and use it in GitHub Desktop.
This file contains 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 | |
function penguin_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { | |
if ( 'Penguin800X400' === $size ) { | |
$attr['sizes'] = '(max-width: 767px) calc(100vw - 30px), (max-width: 991px) 469px, (max-width: 1199px) 696.5px, 414px'; | |
} | |
if ( 'Penguin800X400' === $size && ( is_sticky() ) ) { | |
$attr['sizes'] = '(max-width: 767px) calc(100vw - 30px), (max-width: 991px) 469px, (max-width: 1199px) 696.5px, 846.5px'; | |
} | |
if ( 'full' === $size && ( is_singular() ) ) { | |
$attr['sizes'] = '100vw'; | |
} | |
return $attr; | |
} | |
add_filter( 'wp_get_attachment_image_attributes', 'penguin_post_thumbnail_sizes_attr', 10 , 3 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment