Make WordPress Core

Changeset 62027


Ignore:
Timestamp:
03/14/2026 04:00:01 PM (3 months ago)
Author:
joedolson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r61841 r62027  
    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;
Note: See TracChangeset for help on using the changeset viewer.