mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Media: Don't generate responsive image attributes if src does not match ID in wp-image- class.
We rely on the `wp-image-` class to quickly find an attachment ID to add responsive image attributes. To avoid incorrect images being displayed, do not add these attributes if the `src` does not match the meta from the attachment ID in the class. Props azaozz, kovshenin, joemcgill. Fixes: #34898. git-svn-id: https://develop.svn.wordpress.org/trunk@35820 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1058,6 +1058,26 @@ EOF;
|
||||
$this->assertSame( $content_filtered, wp_make_content_images_responsive( $content_unfiltered ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* When rendering attributes for responsive images,
|
||||
* we rely on the 'wp-image-*' class to find the image by ID.
|
||||
* The class name may not be consistent with attachment IDs in DB when
|
||||
* working with imported content or when a user has edited
|
||||
* the 'src' attribute manually. To avoid incorrect images
|
||||
* being displayed, ensure we don't add attributes in this case.
|
||||
*
|
||||
* @ticket 34898
|
||||
* @ticket 33641
|
||||
*/
|
||||
function test_wp_make_content_images_responsive_wrong() {
|
||||
$image = get_image_tag( self::$large_id, '', '', '', 'medium' );
|
||||
|
||||
// Replace the src URL
|
||||
$image_wrong_src = preg_replace( '|src="[^"]+"|', 'src="http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/foo.jpg"', $image );
|
||||
|
||||
$this->assertSame( $image_wrong_src, wp_make_content_images_responsive( $image_wrong_src ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 33641
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user