Make WordPress Core


Ignore:
Timestamp:
03/10/2015 05:06:39 AM (10 years ago)
Author:
SergeyBiryukov
Message:

EXIF/IPTC captions should populate Caption (post_excerpt) on upload, not Description (post_content).

Make sure the caption is always set if found. Previously, if the caption was less than 80 characters, only the Title field would be set.

props beaulebens, ericlewis, bendoh, SergeyBiryukov.
fixes #22768.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r31645 r31694  
    300300            if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption
    301301                $caption = trim( $iptc['2#120'][0] );
    302                 if ( empty( $meta['title'] ) ) {
    303                     mbstring_binary_safe_encoding();
    304                     $caption_length = strlen( $caption );
    305                     reset_mbstring_encoding();
    306 
     302
     303                mbstring_binary_safe_encoding();
     304                $caption_length = strlen( $caption );
     305                reset_mbstring_encoding();
     306
     307                if ( empty( $meta['title'] ) && $caption_length < 80 ) {
    307308                    // Assume the title is stored in 2:120 if it's short.
    308                     if ( $caption_length < 80 ) {
    309                         $meta['title'] = $caption;
    310                     } else {
    311                         $meta['caption'] = $caption;
    312                     }
    313                 } elseif ( $caption != $meta['title'] ) {
    314                     $meta['caption'] = $caption;
     309                    $meta['title'] = $caption;
    315310                }
     311
     312                $meta['caption'] = $caption;
    316313            }
    317314
     
    347344                // Assume the title is stored in ImageDescription
    348345                $meta['title'] = trim( $exif['ImageDescription'] );
    349                 if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) {
    350                     $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
    351                 }
    352             } elseif ( empty( $meta['caption'] ) && trim( $exif['ImageDescription'] ) != $meta['title'] ) {
     346            }
     347
     348            if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) {
     349                $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] );
     350            }
     351
     352            if ( empty( $meta['caption'] ) ) {
    353353                $meta['caption'] = trim( $exif['ImageDescription'] );
    354354            }
    355         } elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) && trim( $exif['Comments'] ) != $meta['title'] ) {
     355        } elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) ) {
    356356            $meta['caption'] = trim( $exif['Comments'] );
    357357        }
Note: See TracChangeset for help on using the changeset viewer.