Title: wp_calculate_image_srcset_meta
Published: February 2, 2016
Last modified: May 20, 2026

---

# apply_filters( ‘wp_calculate_image_srcset_meta’, array $image_meta, int[] $size_array, string $image_src, int $attachment_id )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#wp--skip-link--target)

Pre-filters the image meta to be able to fix inconsistencies in the stored data.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#parameters)󠁿

 `$image_meta`array

The image meta data as returned by ‘[wp_get_attachment_metadata()](https://developer.wordpress.org/reference/functions/wp_get_attachment_metadata/)‘.

`$size_array`int[]

An array of requested width and height values.

 * `0` int
 * The width in pixels.
 * `1` int
 * The height in pixels.

`$image_src`string

The `'src'` of the image.

`$attachment_id`int

The image attachment ID or 0 if not supplied.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#source)󠁿

    ```php
    $image_meta = apply_filters( 'wp_calculate_image_srcset_meta', $image_meta, $size_array, $image_src, $attachment_id );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/media.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/media.php#L1359)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/media.php#L1359-L1359)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_calculate_image_srcset()](https://developer.wordpress.org/reference/functions/wp_calculate_image_srcset/)`wp-includes/media.php` |

A helper function to calculate the image sources to include in a ‘srcset’ attribute.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/wp_calculate_image_srcset_meta/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.5.0](https://developer.wordpress.org/reference/since/4.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fwp_calculate_image_srcset_meta%2F)
before being able to contribute a note or feedback.