wp_calculate_image_sizes
Filter HookDescription
Filters the output of 'wp_calculate_image_sizes()'.Hook Information
File Location |
wp-includes/media.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1618 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$sizes
|
A source size value for use in a 'sizes' attribute. |
string|int[]
|
$size
|
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order). |
string|null
|
$image_src
|
The URL to the image file or null. |
array|null
|
$image_meta
|
The image meta data as returned by wp_get_attachment_metadata() or null. |
int
|
$attachment_id
|
Image attachment ID of the original image or 0. |
Usage Examples
Basic Usage
<?php
// Hook into wp_calculate_image_sizes
add_filter('wp_calculate_image_sizes', 'my_custom_filter', 10, 5);
function my_custom_filter($sizes, $size, $image_src, $image_meta, $attachment_id) {
// Your custom filtering logic here
return $sizes;
}
Source Code Context
wp-includes/media.php:1618
- How this hook is used in WordPress core
<?php
1613 * an array of width and height values in pixels (in that order).
1614 * @param string|null $image_src The URL to the image file or null.
1615 * @param array|null $image_meta The image meta data as returned by wp_get_attachment_metadata() or null.
1616 * @param int $attachment_id Image attachment ID of the original image or 0.
1617 */
1618 return apply_filters( 'wp_calculate_image_sizes', $sizes, $size, $image_src, $image_meta, $attachment_id );
1619 }
1620
1621 /**
1622 * Determines if the image meta data is for the image source file.
1623 *
PHP Documentation
<?php
/**
* Filters the output of 'wp_calculate_image_sizes()'.
*
* @since 4.4.0
*
* @param string $sizes A source size value for use in a 'sizes' attribute.
* @param string|int[] $size Requested image size. Can be any registered image size name, or
* an array of width and height values in pixels (in that order).
* @param string|null $image_src The URL to the image file or null.
* @param array|null $image_meta The image meta data as returned by wp_get_attachment_metadata() or null.
* @param int $attachment_id Image attachment ID of the original image or 0.
*/
Quick Info
- Hook Type: Filter
- Parameters: 5
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.