wp_calculate_image_srcset WordPress Filter Hook

The wp_calculate_image_srcset hook is used to calculate the image srcset attribute. This hook is used to filter the image srcset attribute.

apply_filters( 'wp_calculate_image_srcset', array $sources, array $size_array, string $image_src, array $image_meta, int $attachment_id ) #

Filters an image’s ‘srcset’ sources.


Parameters

$sources

(array)One or more arrays of source data to include in the 'srcset'.

  • 'width'
    (array)
    • 'url'
      (string) The URL of an image source.
    • 'descriptor'
      (string) The descriptor type used in the image candidate string, either 'w' or 'x'.
    • 'value'
      (int) The source width if paired with a 'w' descriptor, or a pixel density value if paired with an 'x' descriptor.

$size_array

(array)An array of requested width and height values.

  • (int) The width in pixels.
  • '1'
    (int) The height in pixels.

$image_src

(string)The 'src' of the image.

$image_meta

(array)The image meta data as returned by 'wp_get_attachment_metadata()'.

$attachment_id

(int)Image attachment ID or 0.


Top ↑

Source

File: wp-includes/media.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More