wp_generate_attachment_metadata
Filter HookDescription
Filters the generated attachment meta data.Hook Information
File Location |
wp-admin/includes/image.php
View on GitHub
|
Hook Type | Filter |
Line Number | 750 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$metadata
|
An array of attachment meta data. |
int
|
$attachment_id
|
Current attachment ID. |
string
|
$context
|
Additional context. Can be 'create' when metadata was initially created for new attachment or 'update' when the metadata was updated. |
Usage Examples
Basic Usage
<?php
// Hook into wp_generate_attachment_metadata
add_filter('wp_generate_attachment_metadata', 'my_custom_filter', 10, 3);
function my_custom_filter($metadata, $attachment_id, $context) {
// Your custom filtering logic here
return $metadata;
}
Source Code Context
wp-admin/includes/image.php:750
- How this hook is used in WordPress core
<?php
745 * @param array $metadata An array of attachment meta data.
746 * @param int $attachment_id Current attachment ID.
747 * @param string $context Additional context. Can be 'create' when metadata was initially created for new attachment
748 * or 'update' when the metadata was updated.
749 */
750 return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id, 'create' );
751 }
752
753 /**
754 * Converts a fraction string to a decimal.
755 *
PHP Documentation
<?php
/**
* Filters the generated attachment meta data.
*
* @since 2.1.0
* @since 5.3.0 The `$context` parameter was added.
*
* @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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-admin/includes/image.php
Related Hooks
Related hooks will be displayed here in future updates.