wp_calculate_image_srcset_meta
Filter HookDescription
Pre-filters the image meta to be able to fix inconsistencies in the stored data. }Hook Information
File Location |
wp-includes/media.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1345 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$image_meta
|
The image meta data as returned by 'wp_get_attachment_metadata()'. |
int[]
|
$size_array
|
{ An array of requested width and height values. |
string
|
$image_src
|
The 'src' of the image. |
int
|
$attachment_id
|
The image attachment ID or 0 if not supplied. |
Usage Examples
Basic Usage
<?php
// Hook into wp_calculate_image_srcset_meta
add_filter('wp_calculate_image_srcset_meta', 'my_custom_filter', 10, 4);
function my_custom_filter($image_meta, $size_array, $image_src, $attachment_id) {
// Your custom filtering logic here
return $image_meta;
}
Source Code Context
wp-includes/media.php:1345
- How this hook is used in WordPress core
<?php
1340 * @type int $1 The height in pixels.
1341 * }
1342 * @param string $image_src The 'src' of the image.
1343 * @param int $attachment_id The image attachment ID or 0 if not supplied.
1344 */
1345 $image_meta = apply_filters( 'wp_calculate_image_srcset_meta', $image_meta, $size_array, $image_src, $attachment_id );
1346
1347 if ( empty( $image_meta['sizes'] ) || ! isset( $image_meta['file'] ) || strlen( $image_meta['file'] ) < 4 ) {
1348 return false;
1349 }
1350
PHP Documentation
<?php
/**
* Pre-filters the image meta to be able to fix inconsistencies in the stored data.
*
* @since 4.5.0
*
* @param array $image_meta The image meta data as returned by 'wp_get_attachment_metadata()'.
* @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.
* }
* @param string $image_src The 'src' of the image.
* @param int $attachment_id The image attachment ID or 0 if not supplied.
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.