Opened 10 years ago
Closed 10 years ago
#820 closed defect (bug) (fixed)
Codex page for wp_read_image_metadata gives wrong order for image meta determination
Reported by: | theMikeD | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Component: | Codex | Keywords: | |
Cc: |
Description
The codex page for wp_read_image_metadata()
describes how the various meta values are determined by reading IPTC and EXIF info embedded into the image header. Specifically it outlines the order used to populate the image metadata. The order shown is wrong for title, copyright, caption and credit. I've confirmed that it's wrong by making a logic block of the code, and by testing with the various IPTC and EXIF header info set.
For example, for "title" codex lists the following as the order of preference:
- EXIF Title field
- IPTC Headline field (2#105)
- IPTC Title field (2#005)
- IPTC Caption field (2#120) but only if less than 80 characters
- EXIF ImageDescription field but only if less than 80 characters
Looking at the code, the correct order is
- IPTC:Headline
- IPTC:Title
- IPTC:Description if less than 80 characters
- EXIF:Title
- EXIF:Description if less than 80 characters
This is confirmed additionally by looking at the comments in the code, one of which states:
* Read IPTC first, since it might contain data not available in exif such * as caption, description etc.
Here are the correct orders:
title:
- IPTC:Headline
- IPTC:Title
- IPTC:Description if less than 80 characters
- EXIF:Title
- EXIF:ImageDescription if less than 80 characters
caption:
- IPTC:Description
- EXIF:UserComment if title is unset AND EXIF:ImageDescription is less than 80 characters
- EXIF:ImageDescription if title is set OR EXIF:ImageDescription is more than 80 characters
- EXIF:Comments if title !== EXIF:Comments
credit:
- IPTC:Credit
- IPTC:Creator
- EXIF:Artist
- EXIF:Author
copyright:
- IPTC:Copyright
- EXIF:Copyright
The codex is a wiki. Feel free to log in there and correct it. Your forum username and password will work.