Skip to content

Commit 6dac3b4

Browse files
committed
Media: Fix logic when checking IPTC alt text meta data.
Fix two conditional checks for validity of data when importing alt text from IPTC meta data. Strictly compare the results of `strpos()` as a boolean, rather than treating 0 as false; return string if `file_get_contents()` returns false. Props suhan2411, pbiron, alexodiy, joedolson. Fixes #64849. git-svn-id: https://develop.svn.wordpress.org/trunk@62027 602fd350-edb4-49c9-b593-d223f7449a82
1 parent debd1f5 commit 6dac3b4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/wp-admin/includes/image.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,11 +1088,16 @@ function wp_read_image_metadata( $file ) {
10881088
function wp_get_image_alttext( $file ) {
10891089
$alt_text = '';
10901090
$img_contents = file_get_contents( $file );
1091+
1092+
if ( false === $img_contents ) {
1093+
return $alt_text;
1094+
}
1095+
10911096
// Find the start and end positions of the XMP metadata.
10921097
$xmp_start = strpos( $img_contents, '<x:xmpmeta' );
10931098
$xmp_end = strpos( $img_contents, '</x:xmpmeta>' );
10941099

1095-
if ( ! $xmp_start || ! $xmp_end ) {
1100+
if ( false === $xmp_start || false === $xmp_end ) {
10961101
// No XMP metadata found.
10971102
return $alt_text;
10981103
}

0 commit comments

Comments
 (0)