Filter hook 'max_srcset_image_width'

in WP Core File wp-includes/media.php at line 1430

View Source

max_srcset_image_width

Filter Hook
Description
Filters the maximum image width to be included in a 'srcset' attribute. }

Hook Information

File Location wp-includes/media.php View on GitHub
Hook Type Filter
Line Number 1430

Hook Parameters

Type Name Description
int $max_width The maximum image width to be included in the 'srcset'. Default '2048'.
int[] $size_array { An array of requested width and height values.

Usage Examples

Basic Usage
<?php
// Hook into max_srcset_image_width
add_filter('max_srcset_image_width', 'my_custom_filter', 10, 2);

function my_custom_filter($max_width, $size_array) {
    // Your custom filtering logic here
    return $max_width;
}

Source Code Context

wp-includes/media.php:1430 - How this hook is used in WordPress core
<?php
1425  	 *
1426  	 *     @type int $0 The width in pixels.
1427  	 *     @type int $1 The height in pixels.
1428  	 * }
1429  	 */
1430  	$max_srcset_image_width = apply_filters( 'max_srcset_image_width', 2048, $size_array );
1431  
1432  	// Array to hold URL candidates.
1433  	$sources = array();
1434  
1435  	/**

PHP Documentation

<?php
/**
	 * Filters the maximum image width to be included in a 'srcset' attribute.
	 *
	 * @since 4.4.0
	 *
	 * @param int   $max_width  The maximum image width to be included in the 'srcset'. Default '2048'.
	 * @param int[] $size_array {
	 *     An array of requested width and height values.
	 *
	 *     @type int $0 The width in pixels.
	 *     @type int $1 The height in pixels.
	 * }
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/media.php
Related Hooks

Related hooks will be displayed here in future updates.