Add option to delete the original file on upload #1606
+94
−17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: