apply_filters( 'wp_generate_attachment_metadata', array $metadata, int $attachment_id, string $context )
- Since
- 2.1.0, 5.3.0
Filters the generated attachment meta data.
Compatibility
- WordPress
- since 5.3.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$metadataarray- An array of attachment meta data.
$attachment_idint- Current attachment ID.
$contextstring- Additional context. Can be 'create' when metadata was initially created for new attachment or 'update' when the metadata was updated.
Where this hook fires · 2
wp-admin/includes/image.php:185wp_update_image_subsizes()wp-admin/includes/image.php:764wp_generate_attachment_metadata()
Source code
* * @param array $metadata An array of attachment meta data. * @param int $attachment_id Current attachment ID. * @param string $context Additional context. Can be 'create' when metadata was initially created for new attachment * or 'update' when the metadata was updated. */ return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id, 'create' );} /** * Converts a fraction string to a decimal. * * @since 2.5.0Changelog
Introduced in 2.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
5.3.0
The
$context parameter was added.from the docblock2.1.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.