239 | | $caption = utf8_encode( trim( $iptc['2#120'][0] ) ); |
240 | | if ( empty( $meta['title'] ) ) { |
241 | | // Assume the title is stored in 2:120 if it's short. |
242 | | if ( strlen( $caption ) < 80 ) |
243 | | $meta['title'] = $caption; |
244 | | else |
| 239 | |
| 240 | // Check mimetype using fileinfo, if available |
| 241 | $str = $iptc['2#120'][0]; |
| 242 | $mime_type = ''; |
| 243 | if ( extension_loaded('fileinfo') ) { |
| 244 | $finfo = new finfo(); |
| 245 | $mime_type = $finfo->buffer( $str, FILEINFO_MIME ); |
| 246 | unset( $finfo ); |
| 247 | |
| 248 | // If fileinfo isn't available, check the caption for printable characters |
| 249 | } elseif ( ctype_print($str) ) { |
| 250 | $mime_type = 'text/plain'; |
| 251 | } |
| 252 | |
| 253 | if ( 'text' == substr( $mime_type, 0, 4 ) ) { |
| 254 | $caption = utf8_encode( trim( $iptc['2#120'][0] ) ); |
| 255 | if ( empty( $meta['title'] ) ) { |
| 256 | // Assume the title is stored in 2:120 if it's short. |
| 257 | if ( strlen( $caption ) < 80 ) |
| 258 | $meta['title'] = $caption; |
| 259 | else |
| 260 | $meta['caption'] = $caption; |
| 261 | } elseif ( $caption != $meta['title'] ) { |