Changeset 58974 for trunk/tests/phpunit/tests/media.php
- Timestamp:
- 09/03/2024 05:05:33 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/media.php
r58773 r58974 5580 5580 5581 5581 /** 5582 * Tests that wp_img_tag_add_loading_optimization_attrs() passes the 'src' attribute to wp_get_loading_optimization_attributes(). 5583 * 5584 * @ticket 61436 5585 * 5586 * @covers ::wp_img_tag_add_loading_optimization_attrs 5587 */ 5588 public function test_wp_img_tag_add_loading_optimization_attrs_passes_src() { 5589 add_filter( 5590 'wp_get_loading_optimization_attributes', 5591 static function ( $loading_attrs, $tag_name, $attr ) { 5592 if ( 5593 'img' === $tag_name && 5594 isset( $attr['src'] ) && 5595 'https://example.org/a-specific-image.jpg' === $attr['src'] 5596 ) { 5597 $loading_attrs['fetchpriority'] = 'low'; 5598 $loading_attrs['loading'] = 'eager'; 5599 } 5600 return $loading_attrs; 5601 }, 5602 10, 5603 3 5604 ); 5605 5606 $image = '<img src="https://example.org/a-specific-image.jpg" width="1280" height="720">'; 5607 $expected = '<img fetchpriority="low" loading="eager" decoding="async" src="https://example.org/a-specific-image.jpg" width="1280" height="720">'; 5608 5609 // Ensure attributes are modified because image src was matched. 5610 $this->assertSame( 5611 $expected, 5612 wp_img_tag_add_loading_optimization_attrs( $image, 'the_content' ), 5613 'fetchpriority should be low when src is matched.' 5614 ); 5615 } 5616 5617 /** 5582 5618 * @ticket 58235 5583 5619 *
Note: See TracChangeset
for help on using the changeset viewer.