• 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_content_image_sizes_attr() – Add custom image sizes attribute to enhance responsive image functionality for content images.

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 = twentyseventeen_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: twentyseventeen/functions.php
Lines:

1 to 15 of 15
function twentyseventeen_content_image_sizes_attr( $sizes, $size ) {
  $width = $size[0];

  if ( 740 <= $width ) {
    $sizes = '(max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px';
  }

  if ( is_active_sidebar( 'sidebar-1' ) || is_archive() || is_search() || is_home() || is_page() ) {
    if ( ! ( is_page() && 'one-column' === get_theme_mod( 'page_options' ) ) && 767 <= $width ) {
      $sizes = '(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px';
    }
  }

  return $sizes;
}
 

 View on GitHub View on Trac

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

Primary Sidebar

Information

Function name: twentyseventeen_content_image_sizes_attr
Plugin ref: Twenty Seventeen
Version: 3.1
Sourcefile: functions.php
File ref: functions.php
Deprecated?: No
API Letters: A,C,I,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