Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Penguin img sizes
<?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
You can’t perform that action at this time.