diff --git a/includes/sanitizers/class-amp-img-sanitizer.php b/includes/sanitizers/class-amp-img-sanitizer.php index 4f4169b729d..45d4e3c9b3a 100644 --- a/includes/sanitizers/class-amp-img-sanitizer.php +++ b/includes/sanitizers/class-amp-img-sanitizer.php @@ -129,6 +129,10 @@ private function filter_attributes( $attributes ) { $out[ $name ] = $this->sanitize_dimension( $value, $name ); break; + case 'data-amp-layout': + $out['layout'] = $value; + break; + default: break; } diff --git a/tests/test-amp-img-sanitizer.php b/tests/test-amp-img-sanitizer.php index 557b9faa675..52889dd1097 100644 --- a/tests/test-amp-img-sanitizer.php +++ b/tests/test-amp-img-sanitizer.php @@ -12,42 +12,47 @@ public function setUp() { public function get_data() { return array( - 'no_images' => array( + 'no_images' => array( '

Lorem Ipsum Demet Delorit.

', '

Lorem Ipsum Demet Delorit.

', ), - 'image_without_src' => array( + 'image_without_src' => array( '

', '

', ), - 'image_with_empty_src' => array( + 'image_with_empty_src' => array( '

', '

', ), - 'image_with_self_closing_tag' => array( + 'image_with_layout' => array( + '', + '', + ), + + 'image_with_self_closing_tag' => array( 'Placeholder!', '', ), - 'image_with_no_end_tag' => array( + 'image_with_no_end_tag' => array( 'Placeholder!', '', ), - 'image_with_end_tag' => array( + 'image_with_end_tag' => array( 'Placeholder!', '', ), - 'image_with_on_attribute' => array( + 'image_with_on_attribute' => array( '', '', ), - 'image_with_blacklisted_attribute' => array( + 'image_with_blacklisted_attribute' => array( '', '', ), @@ -62,17 +67,17 @@ public function get_data() { '', ), - 'gif_image_conversion' => array( + 'gif_image_conversion' => array( 'Placeholder!', '', ), - 'gif_image_url_with_querystring' => array( + 'gif_image_url_with_querystring' => array( 'Placeholder!', '', ), - 'multiple_same_image' => array( + 'multiple_same_image' => array( ' @@ -81,7 +86,7 @@ public function get_data() { '', ), - 'multiple_different_images' => array( + 'multiple_different_images' => array( '