Skip to content

Modern Image Formats: Add test comparing WebP and JPEG sub-size dimensions - #2704

Closed
sonali195 wants to merge 4 commits into
WordPress:trunkfrom
sonali195:fix/issue-1234-short-description
Closed

sonali195 wants to merge 4 commits into
WordPress:trunkfrom
sonali195:fix/issue-1234-short-description

Conversation

@sonali195

@sonali195 sonali195 commented Oct 9, 2026 •

Copy link
Copy Markdown

Summary

Adds a PHPUnit test checking that each WebP sub-size has the same width and height as the matching JPEG sub-size in the attachment metadata, using an image large enough to be scaled.

This adds regression test coverage to ensure dimension consistency between WebP and JPEG sub-sizes.

Relevant technical choices

  • Adds the test_it_should_create_webp_subsizes_with_the_same_dimensions_as_the_jpeg_subsizes test method in plugins/webp-uploads/tests/test-load.php.
  • Uses big_image_size_threshold set to 850px to ensure scaled sub-sizes are created for leaves.jpg.
  • Iterates over the attachment metadata sizes and verifies the actual dimensions of the generated WebP sub-size files match the expected JPEG sub-size dimensions using wp_getimagesize().
  • Does not modify any existing tests or plugin behavior.

How to test

  1. Run npm run wp-env-test start.
  2. Run npm run test-php -- --filter test_it_should_create_webp_subsizes_with_the_same_dimensions.

Use of AI Tools

I used Claude to help draft the test. I reviewed the implementation, formatted it to WordPress standards, and ran the test suite myself.

sonali195 and others added 4 commits October 6, 2026 11:28
Hi! I'd like to work on this. I'm going to start by adding a PHPUnit test that
compares the WebP sub-size dimensions with the JPEG sub-sizes in the metadata,
to reproduce the problem. Is this still available?
Fix test formatting for coding standards
@github-actions github-actions Bot added the [Plugin] Modern Image Formats Formerly WebP Uploads [slug: webp-uploads] label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

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: sonali195 <sonaliprajapati@git.wordpress.org>

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Modern Image Formats Formerly WebP Uploads [slug: webp-uploads]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant