WordPress: Add IPTC keywords and category metadata to uploaded images
Add IPTC keywords and category to image…
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<code>function fifteenccgal_add_additional_image_meta( $meta, $file, $sourceImageType ) { $image_file_types = apply_filters( 'wp_read_image_metadata_types', array( IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ) ); // Check that it's an image type if ( in_array( $sourceImageType, $image_file_types ) && function_exists('iptcparse') ) { getimagesize($file, $info); $iptc = iptcparse($info['APP13']); $meta['category'] = $iptc['2#015']; $meta['keywords'] = $iptc['2#025']; } return $meta; } add_filter('wp_read_image_metadata', 'fifteenccgal_add_additional_image_meta', 10, 3); </code> |


