Skip to content

Prevent PICTURE element when JPEG output is disabled#1378

Merged
adamsilverstein merged 1 commit intoWordPress:trunkfrom
dhananjaykuber:fix/1375-prevent-jpeg-output-when-disabled
Jul 22, 2024
Merged

Prevent PICTURE element when JPEG output is disabled#1378
adamsilverstein merged 1 commit intoWordPress:trunkfrom
dhananjaykuber:fix/1375-prevent-jpeg-output-when-disabled

Conversation

@dhananjaykuber
Copy link
Copy Markdown
Contributor

Summary

Fixes #1375

Relevant technical choices

This PR addresses an issue where the <picture> element was being served even when the "Also output JPEG" option was disabled. The fix involves updating the webp_uploads_is_picture_element_enabled() function to check if JPEG fallback is enabled before returning true.

The change is as follows:

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

This ensures that the picture element is only used when both the "Also output JPEG" and "Picture element" options are enabled, preventing scenarios where both the and elements reference the same AVIF image.

Screenshot 2024-07-19 at 1 01 54 PM

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhananjaykuber <dhananjaykuber@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: westonruter <westonruter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mukeshpanchal27 mukeshpanchal27 added [Type] Bug An existing feature is broken [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) labels Jul 19, 2024
@mukeshpanchal27 mukeshpanchal27 added this to the webp-uploads n.e.x.t milestone Jul 19, 2024
@mukeshpanchal27 mukeshpanchal27 added the skip changelog PRs that should not be mentioned in changelogs label Jul 19, 2024
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@adamsilverstein adamsilverstein merged commit 58447e0 into WordPress:trunk Jul 22, 2024
@westonruter westonruter changed the title WebP Uploads: Prevent picture element when JPEG output is disabled Prevent PICTURE element when JPEG output is disabled Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) skip changelog PRs that should not be mentioned in changelogs [Type] Bug An existing feature is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants