Changeset 57267
- Timestamp:
- 01/10/2024 09:57:50 PM (9 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image.php
r56743 r57267 864 864 } 865 865 866 $exif_description = ''; 867 $exif_usercomment = ''; 866 868 if ( ! empty( $exif['ImageDescription'] ) ) { 869 $exif_description = trim( $exif['ImageDescription'] ); 870 } 871 872 if ( ! empty( $exif['COMPUTED']['UserComment'] ) ) { 873 $exif_usercomment = trim( $exif['COMPUTED']['UserComment'] ); 874 } 875 876 if ( $exif_description ) { 867 877 mbstring_binary_safe_encoding(); 868 $description_length = strlen( $exif ['ImageDescription']);878 $description_length = strlen( $exif_description ); 869 879 reset_mbstring_encoding(); 870 871 880 if ( empty( $meta['title'] ) && $description_length < 80 ) { 872 881 // Assume the title is stored in ImageDescription. 873 $meta['title'] = trim( $exif['ImageDescription'] ); 874 } 875 876 if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) ) { 877 $meta['caption'] = trim( $exif['COMPUTED']['UserComment'] ); 882 $meta['title'] = $exif_description; 883 } 884 885 // If both user comments and description are present. 886 if ( empty( $meta['caption'] ) && $exif_description && $exif_usercomment ) { 887 if ( ! empty( $meta['title'] ) && $exif_description === $meta['title'] ) { 888 $caption = $exif_usercomment; 889 } else { 890 if ( $exif_description === $exif_usercomment ) { 891 $caption = $exif_description; 892 } else { 893 $caption = trim( $exif_description . ' ' . $exif_usercomment ); 894 } 895 } 896 $meta['caption'] = $caption; 897 } 898 899 if ( empty( $meta['caption'] ) && $exif_usercomment ) { 900 $meta['caption'] = $exif_usercomment; 878 901 } 879 902 880 903 if ( empty( $meta['caption'] ) ) { 881 $meta['caption'] = trim( $exif['ImageDescription'] ); 904 $meta['caption'] = $exif_description; 905 } 906 } elseif ( empty( $meta['caption'] ) && $exif_usercomment ) { 907 $meta['caption'] = $exif_usercomment; 908 $description_length = strlen( $exif_usercomment ); 909 if ( empty( $meta['title'] ) && $description_length < 80 ) { 910 $meta['title'] = trim( $exif_usercomment ); 882 911 } 883 912 } elseif ( empty( $meta['caption'] ) && ! empty( $exif['Comments'] ) ) { -
trunk/tests/phpunit/tests/image/meta.php
r52269 r57267 52 52 $this->assertSame( '', $out['credit'], 'Credit value not the same' ); 53 53 $this->assertSame( 'NIKON D70', $out['camera'], 'Camera value not the same' ); 54 $this->assertSame( ' ', $out['caption'], 'Caption value not the same' );54 $this->assertSame( 'Copyright Alex Shiels', $out['caption'], 'Caption value not the same' ); 55 55 $this->assertEquals( strtotime( '2007-06-17 21:18:00' ), $out['created_timestamp'], 'Timestamp value not equivalent' ); 56 56 $this->assertSame( '', $out['copyright'], 'Copyright value not the same' ); … … 58 58 $this->assertEquals( 0, $out['iso'], 'Iso value not equivalent' ); // Interesting - a Nikon bug? 59 59 $this->assertEquals( 1 / 500, $out['shutter_speed'], 'Shutter speed value not equivalent' ); 60 $this->assertSame( ' ', $out['title'], 'Title value not the same' );60 $this->assertSame( 'Copyright Alex Shiels', $out['title'], 'Title value not the same' ); 61 61 // $this->assertSame( array( 'Flowers' ), $out['keywords'] ); 62 62 }
Note: See TracChangeset
for help on using the changeset viewer.