Last active
April 2, 2016 09:06
-
-
Save stebrech/27bef414350bd0b11592bc886fd3f289 to your computer and use it in GitHub Desktop.
Penguin img sizes
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_content_image_sizes_attr($size) { | |
// Singular posts with sidebar | |
if ( is_singular() ) { | |
return '(max-width: 599px) calc(100vw - 50px), (max-width: 767px) calc(100vw - 70px), (max-width: 991px) 429px, (max-width: 1199px) 597px, 747px'; | |
} | |
// Page full width without sidebar | |
if ( get_page_template_slug() === 'page-fullwidth.php' ) { | |
return '(max-width: 599px) calc(100vw - 50px), (max-width: 767px) calc(100vw - 70px), (max-width: 991px) 679px, (max-width: 1199px) 839px, 1039px'; | |
} | |
// 2 col blog with sidebar | |
else { | |
return '(max-width: 599px) calc(100vw - 50px), (max-width: 767px) calc(100vw - 70px), (max-width: 991px) 429px, (max-width: 1199px) 637px, 354px'; | |
} | |
} | |
add_filter('wp_calculate_image_sizes', 'penguin_content_image_sizes_attr', 10 , 2); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment