You appear to be a bot. Output may be restricted
Description
Add custom image sizes attribute to enhance responsive image functionality for content images
Usage
$string = twentysixteen_content_image_sizes_attr( $sizes, $size );
Parameters
- $sizes
- ( string ) required – A source size value for use in a 'sizes' attribute.
- $size
- ( array ) required – Image size. Accepts an array of width and height values in pixels (in that order).
Returns
string A source size value for use in a content image 'sizes' attribute.
Source
File name: twentysixteen/functions.php
Lines:
1 to 21 of 21
function twentysixteen_content_image_sizes_attr( $sizes, $size ) { $width = $size[0]; if ( 840 <= $width ) { $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px'; } if ( 'page' === get_post_type() ) { if ( 840 > $width ) { $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px'; } } else { if ( 840 > $width && 600 <= $width ) { $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px'; } elseif ( 600 > $width ) { $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px'; } } return $sizes; }