- if ( is_callable('iptcparse') ) {
- getimagesize($file, $info);
- if ( !empty($info['APP13']) ) {
- $iptc = iptcparse($info['APP13']);
- if ( !empty($iptc['2#110'][0]) ) // credit
+ if ( is_callable( 'iptcparse' ) ) {
+ getimagesize( $file, $info );
+
+ if ( ! empty( $info['APP13'] ) ) {
+ $iptc = iptcparse( $info['APP13'] );
+
+ // headline, "A brief synopsis of the caption."
+ if ( ! empty( $iptc['2#105'][0] ) )
+ $meta['title'] = utf8_encode( trim( $iptc['2#105'][0] ) );
+ // title, "Many use the Title field to store the filename of the image, though the field may be used in many ways."
+ elseif ( ! empty( $iptc['2#005'][0] ) )
+ $meta['title'] = utf8_encode( trim( $iptc['2#005'][0] ) );
+
+ if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
+ $caption = utf8_encode( trim( $iptc['2#120'][0] ) );
+ if ( empty( $meta['title'] ) ) {
+ // Assume the title is stored in 2:120 if it's short.
+ if ( strlen( $caption ) < 80 )
+ $meta['title'] = $caption;
+ else
+ $meta['caption'] = $caption;
+ } elseif ( $caption != $meta['title'] ) {
+ $meta['caption'] = $caption;
+ }
+ }
+
+ if ( ! empty( $iptc['2#110'][0] ) ) // credit