-
Notifications
You must be signed in to change notification settings - Fork 101
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
base: trunk
Are you sure you want to change the base?
Add option to delete the original file on upload #1606
Conversation
- Add helper to check option value - Register setting to delete original image file - Update original_image metadata before deleting - Remove option on plugin uninstall
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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! |
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
orwebp
format.Update the existing test cases by removing
-jpg
/-jpeg
/-png
from filenames checks.Screenshot: