Media: In wp_read_image_metadata(), include IPTC Keywords when available in $meta.

Adds unit test.

Props swissspidy, dbru, SteveHoneyNZ.
Fixes #33772.


git-svn-id: https://develop.svn.wordpress.org/trunk@34374 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
wonderboymusic
2015-09-22 04:18:02 +00:00
parent 1352d3473a
commit 70b90490fd
2 changed files with 30 additions and 1 deletions

View File

@@ -277,6 +277,7 @@ function wp_read_image_metadata( $file ) {
'shutter_speed' => 0,
'title' => '',
'orientation' => 0,
'keywords' => array(),
);
/*
@@ -325,6 +326,10 @@ function wp_read_image_metadata( $file ) {
if ( ! empty( $iptc['2#116'][0] ) ) // copyright
$meta['copyright'] = trim( $iptc['2#116'][0] );
if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array
$meta['keywords'] = array_values( $iptc['2#025'] );
}
}
}
@@ -410,12 +415,14 @@ function wp_read_image_metadata( $file ) {
* Filter the array of meta data read from an image's exif data.
*
* @since 2.5.0
* @since 4.4.0 The `$iptc` parameter was added.
*
* @param array $meta Image meta data.
* @param string $file Path to image file.
* @param int $sourceImageType Type of image.
* @param array $iptc IPTC data.
*/
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType, $iptc );
}