Skip to content

Picture element: Return additional mime type IMG>src when the responsive image disabled #1448

@mukeshpanchal27

Description

@mukeshpanchal27

Bug Description

WordPress core has a mechanism to disable responsive images through some filters.

add_filter( 'wp_calculate_image_sizes', '__return_false' );

If we disable responsive images, the Enhance Responsive Image plugin still adds the Picture and source. The expected output should be return early only IMG tag.

Steps to reproduce

  1. Add add_filter( 'wp_calculate_image_sizes', '__return_false' ) in your functions.php
  2. Activate the Modern Image Formats plugin and enable picture support from the Media Settings screen.
  3. Add an image block
  4. Preview the page in the front end, See the error.
<picture class="wp-picture-28" style="display: contents;">
 <source 
   type="image/webp"
   srcset="
     http://localhost:8888/wp-content/uploads/2024/08/car-1024x576-jpeg.webp 1024w,
     http://localhost:8888/wp-content/uploads/2024/08/car-300x169-jpeg.webp 300w,
     http://localhost:8888/wp-content/uploads/2024/08/car-768x432-jpeg.webp 768w
   "
 >
 <source
   type="image/jpeg"
   srcset="
     http://localhost:8888/wp-content/uploads/2024/08/car-1024x576.jpeg 1024w,
     http://localhost:8888/wp-content/uploads/2024/08/car-300x169.jpeg 300w,
     http://localhost:8888/wp-content/uploads/2024/08/car-768x432.jpeg 768w
   "
 >
 <img fetchpriority="high" decoding="async" width="1024" height="576" src="http://localhost:8888/wp-content/uploads/2024/08/car-1024x576-jpeg.webp" alt="" class="wp-image-28">
</picture>

Screenshots

Screenshot 2024-08-08 at 4 53 59 PM

Metadata

Metadata

Labels

[Plugin] Modern Image FormatsIssues for the Modern Image Formats plugin (formerly WebP Uploads)[Type] BugAn existing feature is broken

Type

No type
No fields configured for issues without a type.

Projects

Status

Done 😃

Relationships

None yet

Development

No branches or pull requests

Issue actions