Making WordPress.org

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's profile 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:

  1. EXIF Title field
  2. IPTC Headline field (2#105)
  3. IPTC Title field (2#005)
  4. IPTC Caption field (2#120) but only if less than 80 characters
  5. EXIF ImageDescription field but only if less than 80 characters

Looking at the code, the correct order is

  1. IPTC:Headline
  2. IPTC:Title
  3. IPTC:Description if less than 80 characters
  4. EXIF:Title
  5. 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:

  1. IPTC:Headline
  2. IPTC:Title
  3. IPTC:Description if less than 80 characters
  4. EXIF:Title
  5. EXIF:ImageDescription if less than 80 characters

caption:

  1. IPTC:Description
  2. EXIF:UserComment if title is unset AND EXIF:ImageDescription is less than 80 characters
  3. EXIF:ImageDescription if title is set OR EXIF:ImageDescription is more than 80 characters
  4. EXIF:Comments if title !== EXIF:Comments

credit:

  1. IPTC:Credit
  2. IPTC:Creator
  3. EXIF:Artist
  4. EXIF:Author

copyright:

  1. IPTC:Copyright
  2. EXIF:Copyright


Change History (3)

#1 @Otto42
10 years ago

The codex is a wiki. Feel free to log in there and correct it. Your forum username and password will work.

#2 @theMikeD
10 years ago

Great. Done. I referred to this ticket to explain the changes. I guess it can be closed now.

#3 @SergeyBiryukov
10 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.