Opened 9 years ago
Closed 9 years ago
#33772 closed enhancement (fixed)
Include IPTC Keywords in image_metadata array
Reported by: | SteveHoneyNZ | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
IPTC data is already parsed in the attachment metadata process, and use of IPTC keywords is often requested, and there are a number of plugin solutions for using keywords and other IPTC meta.
In core currently the comments around IPTC note that it's selecting only values considered to be "useful" and consistently avaialable. As Adobe and others have almost universally adopted IPTC tag 2#025 as containing keywords it would be useful for developers to have access to these in the image_meta array of attachment_metadata.
The attached demonstrates a small addition to the wp_read_image_metadata function which adds the keywords as a non-indexed array.
Possible negatives - the array values should potentially be escaped/sanitized (I'm unsure what the iptc parse function already does in this respect). Also as attachment_metadata is one serialized db entry images with exceptionally large amonuts of keywords added may become bloated, possibly limit to say 99 by trimming array.
As an example use case I was working on a plugin that bulk creates WooCommerce products from images for print/digital sales, I wanted to add the keywords as product tags for search purposes. With this addition I was able to accomplish that.
Attachments (5)
Change History (19)
#3
@
9 years ago
- Keywords needs-patch added
Hey there, thanks for your report and welcome to trac!
Could you please update a real patch showing the differences between the original file and your changes? You can read more about working with patches here: https://make.wordpress.org/core/handbook/tutorials/trac/submitting-a-patch/
#6
@
9 years ago
- Keywords reporter-feedback added
- Milestone changed from Awaiting Review to Future Release
@SteveHoneyNZ - can you upload an image to the ticket that has that IPTC data for testing?
#7
@
9 years ago
The image above should return the following image_meta array from wp_get_attachment_metadata if patch is working as intended:
[image_meta] => Array ( [aperture] => 8 [credit] => Photoshop Author [camera] => DMC-LX2 [caption] => Photoshop Description [created_timestamp] => 1306315327 [copyright] => Photoshop Copyrright Notice [focal_length] => 6.3 [iso] => 100 [shutter_speed] => 0.0025 [title] => Photoshop Document Ttitle [orientation] => 1 [keywords] => Array ( [0] => beach [1] => baywatch [2] => LA [3] => sunset ) )
#10
@
9 years ago
- Owner set to wonderboymusic
- Resolution set to fixed
- Status changed from new to closed
In 34374:
Also proposing passing the available $iptc array to wp_read_image_metadata filter fired at end of function to allow developers to access any available IPTC tag data and return it the meta array as they wish. Can't see any negative impact of this, and if adding keywords by default isn't thought a good idea as a default, then just including the iptc array in the filter would mean I could still accomplish the same functionality via the filter.