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/tests/phpunit/tests/media.php

    r31574 r31694  
    541541        $this->assertEquals( $expected, $filetype );
    542542    }
     543
     544    /**
     545     * @ticket 22768
     546     */
     547    public function test_media_handle_upload_sets_post_excerpt() {
     548        $iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
     549
     550        // Make a copy of this file as it gets moved during the file upload
     551        $tmp_name = wp_tempnam( $iptc_file );
     552
     553        copy( $iptc_file, $tmp_name );
     554
     555        $_FILES['upload'] = array(
     556            'tmp_name' => $tmp_name,
     557            'name'     => 'test-image-iptc.jpg',
     558            'type'     => 'image/jpeg',
     559            'error'    => 0,
     560            'size'     => filesize( $iptc_file )
     561        );
     562
     563        $post_id = media_handle_upload( 'upload', 0, array(), array( 'action' => 'test_iptc_upload', 'test_form' => false ) );
     564
     565        unset( $_FILES['upload'] );
     566
     567        $post = get_post( $post_id );
     568
     569        $this->assertEquals( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt );
     570    }
     571
    543572}
Note: See TracChangeset for help on using the changeset viewer.