wp_generate_attachment_metadata
Filters the generated attachment meta data.
Description
Parameters (2)
- 0. $metadata (array)
- An array of attachment meta data.
- 1. $attachment_id (int)
- Current attachment ID.
Usage
- To run the hook, copy the example below.
- $metadata = apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
- if ( !empty( $metadata ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the wp_generate_attachment_metadata callback
- function filter_wp_generate_attachment_metadata( $metadata, $attachment_id ) {
- // make filter magic happen here...
- return $metadata;
- };
- // add the filter
- add_filter( 'wp_generate_attachment_metadata', 'filter_wp_generate_attachment_metadata', 10, 2 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'wp_generate_attachment_metadata', 'filter_wp_generate_attachment_metadata', 10, 2 );
Defined (1)
The filter is defined in the following location(s).
- /wp-admin/includes/image.php
- return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );