Changeset 50134
- Timestamp:
- 02/02/2021 02:57:22 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r49979 r50134 1600 1600 */ 1601 1601 function wp_image_src_get_dimensions( $image_src, $image_meta, $attachment_id = 0 ) { 1602 if ( ! wp_image_file_matches_image_meta( $image_src, $image_meta, $attachment_id ) ) { 1603 return false; 1604 } 1602 $dimensions = false; 1605 1603 1606 1604 // Is it a full size image? 1607 1605 if ( strpos( $image_src, $image_meta['file'] ) !== false ) { 1608 returnarray(1606 $dimensions = array( 1609 1607 (int) $image_meta['width'], 1610 1608 (int) $image_meta['height'], … … 1612 1610 } 1613 1611 1614 if ( ! empty( $image_meta['sizes'] ) ) {1612 if ( ! $dimensions && ! empty( $image_meta['sizes'] ) ) { 1615 1613 $src_filename = wp_basename( $image_src ); 1616 1614 1617 1615 foreach ( $image_meta['sizes'] as $image_size_data ) { 1618 1616 if ( $src_filename === $image_size_data['file'] ) { 1619 returnarray(1617 $dimensions = array( 1620 1618 (int) $image_size_data['width'], 1621 1619 (int) $image_size_data['height'], 1622 1620 ); 1621 1622 break; 1623 1623 } 1624 1624 } 1625 1625 } 1626 1626 1627 return false; 1627 /** 1628 * Filter the 'wp_image_src_get_dimensions' value. 1629 * 1630 * @since 5.7.0 1631 * 1632 * @param array|false $dimensions Array with first element being the width 1633 * and second element being the height, or 1634 * false if dimensions could not be determined. 1635 * @param string $image_src The image source file. 1636 * @param array $image_meta The image meta data as returned by 1637 * 'wp_get_attachment_metadata()'. 1638 * @param int $attachment_id The image attachment ID. Default 0. 1639 */ 1640 return apply_filters( 'wp_image_src_get_dimensions', $dimensions, $image_src, $image_meta, $attachment_id ); 1628 1641 } 1629 1642
Note: See TracChangeset
for help on using the changeset viewer.