Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create duplicate image sizes #324

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

ocean90
Copy link
Contributor

@ocean90 ocean90 commented Jan 7, 2025

Description of the Change

Check size of original image before creating a duplicate version of it.

Closes #323

How to test the Change

Upload an image of an avatar size that is used on the site. Ensure that no version is created for this size.

Changelog Entry

Changed - Don't create duplicate image sizes

Credits

Props @ocean90

Checklist:

@jeffpaul jeffpaul added this to the 2.9.0 milestone Jan 7, 2025
@jeffpaul jeffpaul requested review from faisal-alvi and removed request for dkotter and jeffpaul January 14, 2025 03:24
@ocean90 ocean90 requested a review from faisal-alvi January 31, 2025 08:09
Copy link
Member

@faisal-alvi faisal-alvi left a comment

Choose a reason for hiding this comment

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

@ocean90 Thanks for the fix! Could you take a look at why the PHPUnit and Cypress tests started failing? Also, I’ve added a couple of minor suggestions below.

includes/class-simple-local-avatars.php Outdated Show resolved Hide resolved
@ocean90 ocean90 requested a review from faisal-alvi February 7, 2025 11:59
$resized = $editor->resize( $size, $size, true );
if ( ! is_wp_error( $resized ) ) {
$dest_file = $editor->generate_filename();
$saved = $editor->save( $dest_file );
Copy link
Member

Choose a reason for hiding this comment

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

I know this isn't new code, but do you think we should account for the case where generate_filename() returns false?

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.

Don't resize image if the full version already has the expected height/width
3 participants