Skip to content

compress unscaled when original is active#114

Open
tijmenbruggeman wants to merge 10 commits into
tinify:masterfrom
wcreateweb:compress-original-unscaled
Open

compress unscaled when original is active#114
tijmenbruggeman wants to merge 10 commits into
tinify:masterfrom
wcreateweb:compress-original-unscaled

Conversation

@tijmenbruggeman

@tijmenbruggeman tijmenbruggeman commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

WordPress scales down the original image when big_image_size_threshold is hit (defaults to 2560px). The scaled down version will be used when a user requests the full image and generates thumbnails using the unscaled version.

Users wanted to compress the unscaled original image as well as these might take up a lot of disk space.

Changes

  • src/class-tiny-image.php when original image exists, will also add a Tiny_Image_Size for the unscaled version;
  • get_active_tinify_sizes will return the unscaled size when original is enabled;
  • src/class-tiny-settings.php will preserve meta data on the unscaled version if enabled;

Considerations

  • When the original is enabled, it will now count as two compressions as the unscaled version will also account for one. I thought it was better to give an estimate to be on the safe side.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the plugin’s compression behavior to also optimize WordPress’s “unscaled original” file (stored in attachment metadata as original_image) when the scaled original is active, and updates sizing/credit estimation and tests accordingly.

Changes:

  • Add an original_unscaled size concept and create a Tiny_Image_Size for it when original_image exists in attachment metadata.
  • Treat original_unscaled as tied to the original size in settings (including preserve-metadata handling) and update free-compression estimates accordingly.
  • Update unit and Playwright integration tests to reflect the additional implicit compression count.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/class-tiny-image.php Introduces ORIGINAL_UNSCALED and creates an image-size entry from original_image metadata.
src/class-tiny-settings.php Adds original_unscaled into the sizes map and allows preserve options for it; updates docblock typing/text.
test/unit/TinySettingsAdminTest.php Updates expected sizes output and adds coverage for get_active_tinify_sizes() behavior.
test/integration/settings.spec.ts Updates UI expectations for free compression estimates after the new implicit size is counted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/class-tiny-settings.php
Comment thread src/class-tiny-image.php
Comment thread src/class-tiny-settings.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants