Make WordPress Core


Ignore:
Timestamp:
03/10/2015 05:06:39 AM (9 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/media.php

    r31645 r31694  
    281281    $title = $name;
    282282    $content = '';
     283    $excerpt = '';
    283284
    284285    if ( preg_match( '#^audio#', $type ) ) {
    285286        $meta = wp_read_audio_metadata( $file );
    286287
    287         if ( ! empty( $meta['title'] ) )
     288        if ( ! empty( $meta['title'] ) ) {
    288289            $title = $meta['title'];
    289 
    290         $content = '';
     290        }
    291291
    292292        if ( ! empty( $title ) ) {
     
    336336    // Use image exif/iptc data for title and caption defaults if possible.
    337337    } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = @wp_read_image_metadata( $file ) ) {
    338         if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
     338        if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
    339339            $title = $image_meta['title'];
    340         if ( trim( $image_meta['caption'] ) )
    341             $content = $image_meta['caption'];
     340        }
     341
     342        if ( trim( $image_meta['caption'] ) ) {
     343            $excerpt = $image_meta['caption'];
     344        }
    342345    }
    343346
     
    349352        'post_title' => $title,
    350353        'post_content' => $content,
     354        'post_excerpt' => $excerpt,
    351355    ), $post_data );
    352356
Note: See TracChangeset for help on using the changeset viewer.