Skip to content

Disabling "Also output JPEG" does not prevent picture element from being served #1375

@westonruter

Description

@westonruter

Bug Description

I had "Also output JPEG" and "Picture element" enabled. Then I tried turning off "Also output JPEG" and I then uploaded an image. I then unexpectedly got the picture element served, with the img and the source both being the AVIF image:

<picture class="not-transparent wp-picture-76" style="--dominant-color: #749872; display: contents;">
  <source type="image/avif" srcset="http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-1024x588.avif 1024w, http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-300x172.avif 300w, http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-768x441.avif 768w" sizes="(max-width: 1024px) 100vw, 1024px">
  <img data-dominant-color="749872" data-has-transparency="false" fetchpriority="high" decoding="async" width="1024" height="588" src="http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-1024x588.avif" alt="" class="not-transparent wp-image-76" srcset="http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-1024x588.avif 1024w, http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-300x172.avif 300w, http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-768x441.avif 768w, http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-1536x882.avif 1536w, http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-2048x1176.avif 2048w, http://localhost:8888/wp-content/uploads/2024/07/Samango_monkey_Cercopithecus_mitis_erythrarchus_Mount_Sheba-1-1568x901.avif 1568w" sizes="(max-width: 1024px) 100vw, 1024px">
</picture>

This is wrong. The webp_uploads_is_picture_element_enabled() function:

function webp_uploads_is_picture_element_enabled(): bool {
return (bool) get_option( 'webp_uploads_use_picture_element', false );
}

Should be changed to:

function webp_uploads_is_picture_element_enabled(): bool {
	return webp_uploads_is_jpeg_fallback_enabled() && (bool) get_option( 'webp_uploads_use_picture_element', false );
}

Screenshots

image

Metadata

Metadata

Labels

Good First IssueIssue particularly suitable to be worked on by new contributors[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