Changeset 60477
- Timestamp:
- 07/16/2025 02:07:58 PM (5 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-includes/media.php (modified) (3 diffs)
-
tests/phpunit/tests/media.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r60476 r60477 1090 1090 * @param string $context The context. Default 'wp_get_attachment_image'. 1091 1091 */ 1092 $context = apply_filters( 'wp_get_attachment_image_context', 'wp_get_attachment_image' ); 1092 $context = apply_filters( 'wp_get_attachment_image_context', 'wp_get_attachment_image' ); 1093 1093 1094 $attr = wp_parse_args( $attr, $default_attr ); 1094 1095 $attr['width'] = $width; … … 1159 1160 * 1160 1161 * @since 2.8.0 1161 * @since 6.8.2 The `$attr` array includes ` height` and `width` attributes.1162 * @since 6.8.2 The `$attr` array includes `width` and `height` attributes. 1162 1163 * 1163 1164 * @param string[] $attr Array of attribute values for the image markup, keyed by attribute name. … … 1169 1170 $attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size ); 1170 1171 1172 if ( isset( $attr['width'] ) && is_numeric( $attr['width'] ) ) { 1173 $width = absint( $attr['width'] ); 1174 } 1171 1175 if ( isset( $attr['height'] ) && is_numeric( $attr['height'] ) ) { 1172 1176 $height = absint( $attr['height'] ); 1173 1177 } 1174 if ( isset( $attr['width'] ) && is_numeric( $attr['width'] ) ) { 1175 $width = absint( $attr['width'] ); 1176 } 1177 unset( $attr['height'], $attr['width'] ); 1178 unset( $attr['width'], $attr['height'] ); 1179 1178 1180 $attr = array_map( 'esc_attr', $attr ); 1179 1181 $hwstring = image_hwstring( $width, $height ); -
trunk/tests/phpunit/tests/media.php
r60415 r60477 1584 1584 } 1585 1585 1586 public function filter_wp_get_attachment_image() { 1587 return 'Override wp_get_attachment_image'; 1588 } 1589 1586 1590 /** 1587 1591 * @ticket 14110 1588 1592 */ 1589 public function test_wp_get_attachment_image_filter_with_ height_width() {1593 public function test_wp_get_attachment_image_filter_with_width_height() { 1590 1594 $mock_action = new MockAction(); 1591 1595 add_filter( 'wp_get_attachment_image_attributes', array( $mock_action, 'filter' ) ); … … 1601 1605 * @ticket 14110 1602 1606 */ 1603 public function test_wp_get_attachment_image_filter_change_ height_width() {1607 public function test_wp_get_attachment_image_filter_change_width_height() { 1604 1608 add_filter( 1605 1609 'wp_get_attachment_image_attributes', 1606 1610 static function ( $args ) { 1611 $args['width'] = '999'; 1607 1612 $args['height'] = '999'; 1608 $args['width'] = '999';1609 1613 return $args; 1610 1614 } … … 1618 1622 * @ticket 14110 1619 1623 */ 1620 public function test_wp_get_attachment_image_filter_unset_ height_width() {1624 public function test_wp_get_attachment_image_filter_unset_width_height() { 1621 1625 add_filter( 1622 1626 'wp_get_attachment_image_attributes', 1623 1627 static function ( $args ) { 1624 unset( $args[' height'], $args['width'] );1628 unset( $args['width'], $args['height'] ); 1625 1629 return $args; 1626 1630 } … … 1629 1633 $this->assertStringContainsString( 'width="150"', $output, 'Width should not be changed.' ); 1630 1634 $this->assertStringContainsString( 'height="150"', $output, 'Height should not be changed.' ); 1631 }1632 1633 public function filter_wp_get_attachment_image() {1634 return 'Override wp_get_attachment_image';1635 1635 } 1636 1636
Note: See TracChangeset
for help on using the changeset viewer.