Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Add custom image sizes attribute to enhance responsive image functionality
- * for content images
- *
- * @since Twenty Sixteen 1.0
- *
- * @param string $sizes A source size value for use in a 'sizes' attribute.
- * @param array $size Image size. Accepts an array of width and height
- * values in pixels (in that order).
- * @return string A source size value for use in a content image 'sizes' attribute.
- */
- function mvi_content_image_sizes_attr( $sizes, $size ) {
- $width = $size[0];
- 1500 <= $width && $sizes = '(max-width: 768px) 92vw, (max-width: 992px) 700px, (max-width: 1199px) 930px, (min-width: 1200px) 1024px, $width';
- 1500 > $width && $sizes = '(max-width: 754px) 92vw, (min-width: 755px) 697px, $width';
- return $sizes;
- }
- add_filter( 'wp_calculate_image_sizes', 'mvi_content_image_sizes_attr', 10 , 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement