• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / twentyseventeen_post_thumbnail_sizes_attr() – Add custom image sizes attribute to enhance responsive image functionality for post thumbnails.

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;
}
 

 View on GitHub View on Trac

Published: 8th April 2020 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: twentyseventeen_post_thumbnail_sizes_attr
Plugin ref: Twenty Seventeen
Version: 3.1
Sourcefile: functions.php
File ref: functions.php
Deprecated?: No
API Letters: A,P,S,T

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites