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

Add option to delete the original file on upload #1606

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from

Conversation

AhmarZaidi
Copy link
Contributor

@AhmarZaidi AhmarZaidi commented Oct 18, 2024

Summary

Fixes #1564

This pull request introduces a new option in the Modern Image Format plugin settings to delete the original JPEG/PNG files after conversion to modern image formats like AVIF or WebP. This will help save disk space by removing the original files. Also, removed the old extension suffix (eg: -jpg, -png) from the filename.

Relevant technical choices

  • Added a new checkbox option in the settings page to enable or disable the deletion of original JPEG/PNG files after conversion.

  • Updated the original_image metadata when the delete option is enabled so that the original image link in Attachment details popup doesn't give 404.

  • Added checks to ensure that the original file is only deleted if new image files have been generated. Also taken care of the case where the original image itself is in avif or webp format.

  • Update the existing test cases by removing -jpg/-jpeg/-png from filenames checks.

Screenshot:

Screenshot 2024-10-18 at 6 32 53 PM

@AhmarZaidi AhmarZaidi changed the title Feature/delete original option modern image formats Add option to delete the original file on upload Oct 18, 2024
@AhmarZaidi AhmarZaidi marked this pull request as ready for review October 21, 2024 06:20
Copy link

github-actions bot commented Oct 21, 2024

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: AhmarZaidi <[email protected]>
Co-authored-by: adamsilverstein <[email protected]>
Co-authored-by: felixarntz <[email protected]>
Co-authored-by: westonruter <[email protected]>
Co-authored-by: JosVelasco <[email protected]>

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

@adamsilverstein
Copy link
Member

Hey @AhmarZaidi - I appreciate your effort here contributing to the plugin. However, I'm not in favor of including this feature, see my comment on the issue and feel free to disagree if you feel I missed some important aspect. I know you put work into this, so thanks for that!

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.

Modern Image Formats: Option to delete the original file on upload
2 participants