Ticket #50543: 50543.diff
File 50543.diff, 1.9 KB (added by , 4 years ago) |
---|
-
src/wp-includes/media.php
1508 1508 * or false if dimensions cannot be determined. 1509 1509 */ 1510 1510 function wp_image_src_get_dimensions( $image_src, $image_meta ) { 1511 $image_filename = wp_basename( $image_src ); 1511 // Ensure the $image_meta is for this image. For example the attachment ID used to get the meta 1512 // may have changed if the site was exported and then imported, etc. 1513 if ( empty( $image_meta['sizes'] ) || ! isset( $image_meta['file'] ) || strlen( $image_meta['file'] ) < 4 ) { 1514 return false; 1515 } 1512 1516 1513 if ( wp_basename( $image_meta['file'] ) === $image_filename ) { 1517 list( $image_src ) = explode( '?', $image_src ); 1518 1519 // Match the relative image path inside the uploads directory plus the file name. 1520 if ( 1521 strpos( $image_src, $image_meta['file'] ) !== false && 1522 preg_match( '|' . preg_quote( $image_meta['file'] ) . '$|', $image_src ) 1523 ) { 1514 1524 return array( 1515 1525 (int) $image_meta['width'], 1516 1526 (int) $image_meta['height'], … … 1517 1527 ); 1518 1528 } 1519 1529 1530 // Retrieve the uploads sub-directory from the full size image. 1531 $dirname = _wp_get_attachment_relative_path( $image_meta['file'] ); 1532 1533 if ( $dirname ) { 1534 $dirname = trailingslashit( $dirname ); 1535 } 1536 1537 $src_filename = wp_basename( $image_src ); 1538 1520 1539 foreach ( $image_meta['sizes'] as $image_size_data ) { 1521 if ( $image_filename === $image_size_data['file'] ) { 1540 if ( 1541 // First check if the filename matches (cheap), 1542 // then check if the filename and the relative upload directory is at the end of $image_src. 1543 $src_filename === $image_size_data['file'] && 1544 preg_match( '|' . preg_quote( $dirname . $image_size_data['file'] ) . '$|', $image_src ) 1545 ) { 1522 1546 return array( 1523 1547 (int) $image_size_data['width'], 1524 1548 (int) $image_size_data['height'],