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.

git-svn-id: https://develop.svn.wordpress.org/trunk@31694 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2015-03-10 05:06:39 +00:00
parent e0f843cd81
commit 5fe8182c7f
3 changed files with 55 additions and 22 deletions
+29
View File
@@ -540,4 +540,33 @@ VIDEO;
);
$this->assertEquals( $expected, $filetype );
}
/**
* @ticket 22768
*/
public function test_media_handle_upload_sets_post_excerpt() {
$iptc_file = DIR_TESTDATA . '/images/test-image-iptc.jpg';
// Make a copy of this file as it gets moved during the file upload
$tmp_name = wp_tempnam( $iptc_file );
copy( $iptc_file, $tmp_name );
$_FILES['upload'] = array(
'tmp_name' => $tmp_name,
'name' => 'test-image-iptc.jpg',
'type' => 'image/jpeg',
'error' => 0,
'size' => filesize( $iptc_file )
);
$post_id = media_handle_upload( 'upload', 0, array(), array( 'action' => 'test_iptc_upload', 'test_form' => false ) );
unset( $_FILES['upload'] );
$post = get_post( $post_id );
$this->assertEquals( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt );
}
}