You appear to be a bot. Output may be restricted
Description
Add custom image sizes attribute to enhance responsive image functionality for post thumbnails.
Usage
$string[] = twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size );
Parameters
- $attr
- ( string[] ) required – Array of attribute values for the image markup, keyed by attribute name. See wp_get_attachment_image().
- $attachment
- ( WP_Post ) required – Image attachment post.
- $size
- ( string|int[] ) required – Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
Returns
string[] The filtered attributes for the image markup.
Source
File name: twentyseventeen/functions.php
Lines:
1 to 9 of 9
function twentyseventeen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { if ( is_archive() || is_search() || is_home() ) { $attr['sizes'] = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px'; } else { $attr['sizes'] = '100vw'; } return $attr; }