WordPress at a glance
filter is not described

wp_calculate_image_srcset filter-hook . WP 4.4.0

Filters an image's 'srcset' sources.


add_filter( 'wp_calculate_image_srcset', 'filter_function_name_5268', 10, 5 );
function filter_function_name_5268( $sources, $size_array, $image_src, $image_meta, $attachment_id ){
	// filter...

	return $sources;

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.
Array of width and height values in pixels (in that order).
The 'src' of the image.
The image meta data as returned by 'wp_get_attachment_metadata()'.
Image attachment ID or 0.


Since 4.4.0 Introduced.

Where the hook is called

wp-includes/media.php 1318
$sources = apply_filters( 'wp_calculate_image_srcset', $sources, $size_array, $image_src, $image_meta, $attachment_id );

Where the hook is used (in WP core)

Usage not found!