Filter hook 'wp_update_attachment_metadata'

in WP Core File wp-includes/post.php at line 6864

View Source

wp_update_attachment_metadata

Filter Hook
Description
Filters the updated attachment meta data.

Hook Information

File Location wp-includes/post.php View on GitHub
Hook Type Filter
Line Number 6864

Hook Parameters

Type Name Description
array $data Array of updated attachment meta data.
int $attachment_id Attachment post ID.

Usage Examples

Basic Usage
<?php
// Hook into wp_update_attachment_metadata
add_filter('wp_update_attachment_metadata', 'my_custom_filter', 10, 2);

function my_custom_filter($data, $attachment_id) {
    // Your custom filtering logic here
    return $data;
}

Source Code Context

wp-includes/post.php:6864 - How this hook is used in WordPress core
<?php
6859  	 * @since 2.1.0
6860  	 *
6861  	 * @param array $data          Array of updated attachment meta data.
6862  	 * @param int   $attachment_id Attachment post ID.
6863  	 */
6864  	$data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
6865  	if ( $data ) {
6866  		return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
6867  	} else {
6868  		return delete_post_meta( $post->ID, '_wp_attachment_metadata' );
6869  	}

PHP Documentation

<?php
/**
	 * Filters the updated attachment meta data.
	 *
	 * @since 2.1.0
	 *
	 * @param array $data          Array of updated attachment meta data.
	 * @param int   $attachment_id Attachment post ID.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/post.php
Related Hooks

Related hooks will be displayed here in future updates.