From 1d513fe7374871629ffe09f67ee72e6a4e8943ff Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 22 Sep 2015 04:19:24 +0000 Subject: [PATCH] Media: In `wp_read_image_metadata()`, include IPTC Keywords when available in `$meta`. Adds unit test. Props swissspidy, dbru, SteveHoneyNZ. Fixes #33772. Built from https://develop.svn.wordpress.org/trunk@34374 git-svn-id: http://core.svn.wordpress.org/trunk@34338 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 9 ++++++++- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 222d35d015..c21c520ada 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -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 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 8755504419..9c334a4e62 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34373'; +$wp_version = '4.4-alpha-34374'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.