Ticket #9417: 9417.3.patch
| File 9417.3.patch, 5.2 KB (added by SergeyBiryukov, 2 years ago) |
|---|
-
wp-admin/includes/image.php
230 230 231 231 // headline, "A brief synopsis of the caption." 232 232 if ( ! empty( $iptc['2#105'][0] ) ) 233 $meta['title'] = utf8_encode( trim( $iptc['2#105'][0] ) );233 $meta['title'] = wp_iptc_utf8_encode( trim( $iptc['2#105'][0] ) ); 234 234 // title, "Many use the Title field to store the filename of the image, though the field may be used in many ways." 235 235 elseif ( ! empty( $iptc['2#005'][0] ) ) 236 $meta['title'] = utf8_encode( trim( $iptc['2#005'][0] ) );236 $meta['title'] = wp_iptc_utf8_encode( trim( $iptc['2#005'][0] ) ); 237 237 238 238 if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption 239 $caption = utf8_encode( trim( $iptc['2#120'][0] ) );239 $caption = wp_iptc_utf8_encode( trim( $iptc['2#120'][0] ) ); 240 240 if ( empty( $meta['title'] ) ) { 241 241 // Assume the title is stored in 2:120 if it's short. 242 242 if ( strlen( $caption ) < 80 ) … … 249 249 } 250 250 251 251 if ( ! empty( $iptc['2#110'][0] ) ) // credit 252 $meta['credit'] = utf8_encode(trim($iptc['2#110'][0]));252 $meta['credit'] = wp_iptc_utf8_encode(trim($iptc['2#110'][0])); 253 253 elseif ( ! empty( $iptc['2#080'][0] ) ) // creator / legacy byline 254 $meta['credit'] = utf8_encode(trim($iptc['2#080'][0]));254 $meta['credit'] = wp_iptc_utf8_encode(trim($iptc['2#080'][0])); 255 255 256 256 if ( ! empty( $iptc['2#055'][0] ) and ! empty( $iptc['2#060'][0] ) ) // created date and time 257 257 $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] ); 258 258 259 259 if ( ! empty( $iptc['2#116'][0] ) ) // copyright 260 $meta['copyright'] = utf8_encode( trim( $iptc['2#116'][0] ) );260 $meta['copyright'] = wp_iptc_utf8_encode( trim( $iptc['2#116'][0] ) ); 261 261 } 262 262 } 263 263 … … 266 266 $exif = @exif_read_data( $file ); 267 267 268 268 if ( !empty( $exif['Title'] ) ) 269 $meta['title'] = utf8_encode( trim( $exif['Title'] ) );269 $meta['title'] = wp_iptc_utf8_encode( trim( $exif['Title'] ) ); 270 270 271 271 if ( ! empty( $exif['ImageDescription'] ) ) { 272 272 if ( empty( $meta['title'] ) && strlen( $exif['ImageDescription'] ) < 80 ) { 273 273 // Assume the title is stored in ImageDescription 274 $meta['title'] = utf8_encode( trim( $exif['ImageDescription'] ) );274 $meta['title'] = wp_iptc_utf8_encode( trim( $exif['ImageDescription'] ) ); 275 275 if ( ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) 276 $meta['caption'] = utf8_encode( trim( $exif['COMPUTED']['UserComment'] ) );276 $meta['caption'] = wp_iptc_utf8_encode( trim( $exif['COMPUTED']['UserComment'] ) ); 277 277 } elseif ( trim( $exif['ImageDescription'] ) != $meta['title'] ) { 278 $meta['caption'] = utf8_encode( trim( $exif['ImageDescription'] ) );278 $meta['caption'] = wp_iptc_utf8_encode( trim( $exif['ImageDescription'] ) ); 279 279 } 280 280 } elseif ( ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) { 281 $meta['caption'] = utf8_encode( trim( $exif['Comments'] ) );281 $meta['caption'] = wp_iptc_utf8_encode( trim( $exif['Comments'] ) ); 282 282 } 283 283 284 284 if ( ! empty( $exif['Artist'] ) ) 285 $meta['credit'] = utf8_encode( trim( $exif['Artist'] ) );285 $meta['credit'] = wp_iptc_utf8_encode( trim( $exif['Artist'] ) ); 286 286 elseif ( ! empty($exif['Author'] ) ) 287 $meta['credit'] = utf8_encode( trim( $exif['Author'] ) );287 $meta['credit'] = wp_iptc_utf8_encode( trim( $exif['Author'] ) ); 288 288 289 289 if ( ! empty( $exif['Copyright'] ) ) 290 $meta['copyright'] = utf8_encode( trim( $exif['Copyright'] ) );290 $meta['copyright'] = wp_iptc_utf8_encode( trim( $exif['Copyright'] ) ); 291 291 if ( ! empty($exif['FNumber'] ) ) 292 292 $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 ); 293 293 if ( ! empty($exif['Model'] ) ) 294 $meta['camera'] = utf8_encode( trim( $exif['Model'] ) );294 $meta['camera'] = wp_iptc_utf8_encode( trim( $exif['Model'] ) ); 295 295 if ( ! empty($exif['DateTimeDigitized'] ) ) 296 296 $meta['created_timestamp'] = wp_exif_date2ts($exif['DateTimeDigitized'] ); 297 297 if ( ! empty($exif['FocalLength'] ) ) 298 298 $meta['focal_length'] = wp_exif_frac2dec( $exif['FocalLength'] ); 299 299 if ( ! empty($exif['ISOSpeedRatings'] ) ) 300 $meta['iso'] = utf8_encode( trim( $exif['ISOSpeedRatings'] ) );300 $meta['iso'] = wp_iptc_utf8_encode( trim( $exif['ISOSpeedRatings'] ) ); 301 301 if ( ! empty($exif['ExposureTime'] ) ) 302 302 $meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] ); 303 303 } … … 307 307 } 308 308 309 309 /** 310 * UTF8 encode IPTC data 311 * 312 * this is a simple implementation ignoring IPTC documentation: 313 * a) if the data is valid utf8 then there is nothing to do 314 * b) if not, assume ISO-8859-1 and encode it to utf-8 315 * 316 * 317 * @link http://de2.php.net/manual/en/function.iptcparse.php 318 * @link http://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf 319 * 320 * @since 3.2 321 * 322 * @param string $itpc raw IRB value returned by iptcparse() 323 * @return string utf8 encoded value 324 */ 325 function wp_iptc_utf8_encode($itpc) { 326 327 if ( false == seems_utf8($itpc) ) 328 $itpc = utf8_encode($itpc); 329 330 return $itpc; 331 } 332 333 /** 310 334 * Validate that file is an image. 311 335 * 312 336 * @since 2.5.0