wp_generate_attachment_metadata хук-фильтрWP 2.1.0

Filters the generated attachment meta data.

Использование

add_filter( 'wp_generate_attachment_metadata', 'wp_kama_generate_attachment_metadata_filter', 10, 3 );

/**
 * Function for `wp_generate_attachment_metadata` filter-hook.
 * 
 * @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 array
 */
function wp_kama_generate_attachment_metadata_filter( $metadata, $attachment_id, $context ){

	// filter...
	return $metadata;
}
$metadata(массив)
An array of attachment meta data.
$attachment_id(int)
Current attachment ID.
$context(строка)
Additional context. Can be 'create' when metadata was initially created for new attachment or 'update' when the metadata was updated.

Список изменений

С версии 2.1.0 Введена.
С версии 5.3.0 The $context parameter was added.

Где вызывается хук

wp_generate_attachment_metadata()
wp_generate_attachment_metadata
wp_update_image_subsizes()
wp_generate_attachment_metadata
wp-admin/includes/image.php 658
return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id, 'create' );
wp-admin/includes/image.php 181
$image_meta = apply_filters( 'wp_generate_attachment_metadata', $image_meta, $attachment_id, 'update' );

Где используется хук в WordPress

Использование не найдено.