-
Notifications
You must be signed in to change notification settings - Fork 26
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
Restore Retina Support (via WP Retina 2x, aka Perfect Images, plugin compat) #656
base: develop
Are you sure you want to change the base?
Commits on Jan 26, 2022
-
Add code for WPR2x that was removed from 68c489b
This is just grabbing the WPR2X code that was deleted. It's no longer wired into our stuff, so it won't do anything yet.
Configuration menu - View commit details
-
Copy full SHA for 6587bb3 - Browse repository at this point
Copy the full SHA 6587bb3View commit details
Commits on Jan 31, 2022
-
Update namespacing, classnames and autoloading
PHPCS - update minimum PHP version to 7.0 Rename wp-retina-2x classes to PerfectImages and add namespace Add PerfectImages namespace to composer PSR4 Use new class names in 3rd-party PerfectImages loader file Add PerfectImages fileloader to 3rd-party required files Stop using deprecated user_can() check - use WP context user check instead Update asset script localization to use updated enqueue
Configuration menu - View commit details
-
Copy full SHA for de402a0 - Browse repository at this point
Copy the full SHA de402a0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 48bce9e - Browse repository at this point
Copy the full SHA 48bce9eView commit details -
Add back js assets previously removed
The 3 assets here were included by the previous compatibility. (Not sure yet if we will still need them, but adding them back because they are still trying to be loaded on library page -- until we can sort it out.)
Configuration menu - View commit details
-
Copy full SHA for 4ffeb21 - Browse repository at this point
Copy the full SHA 4ffeb21View commit details
Commits on Feb 2, 2022
-
Use min WP version 5.3 for phpcs
The WP min version is set in the plugin.php to 5.3 -- phpcs should match.
Configuration menu - View commit details
-
Copy full SHA for 33b21c3 - Browse repository at this point
Copy the full SHA 33b21c3View commit details -
Configuration menu - View commit details
-
Copy full SHA for 77d4753 - Browse repository at this point
Copy the full SHA 77d4753View commit details -
Configuration menu - View commit details
-
Copy full SHA for b45a06b - Browse repository at this point
Copy the full SHA b45a06bView commit details -
Add PerfectImages methods for retina generation
Add first a new property `$retina_sizes[]` to store some size info when Perfect Images generates a new retina file. Comment out (for now) the old ajax hooks, as Perfect Image no longer uses ajax. Add 3 methods: 1. `add_retina_sizes(int $media_id, string $retina_file, string $size_name): void` hooked to Perfect Images `wr2x_retina_file_added `, will store the media ID, retina filepath, and size name in our new `$retina_sizes` property whenever Perfect Images generates a new retina file. 2. `optimize_retina_sizes(int $media_id): void` hooked to Perfect Images `wr2x_generate_retina`, will find all the retina sizes added at the end of a Perfect Images retina generation process for a media ID (as stored in our class property) and start a new Imagify Optimization process for the newly generated retina files. 3. `add_retina_sizes_meta(array $sizes): array` hooked to Imagify's `imagify_media_files` will filter the imagify Media size meta to include the retina sizes, and flag the new sizes as being allowed to optimize.
Configuration menu - View commit details
-
Copy full SHA for f8e7761 - Browse repository at this point
Copy the full SHA f8e7761View commit details
Commits on Feb 4, 2022
-
Add methods for deleting retinas
We add 4 methods here, 2 public, and 2 private helpers: The 2 public methods are both hooked on Perfect Images `wr2x_retina_file_removed` action. 1. `remove_retina_webp_size(int $media_id, string $retina_file ): void` will check for any webp versions of the retina file that was deleted and remove it if it exists. Note we run this even if Imagify's webp option is not currently enabled, because it may have been enabled at the time the retina was generated, and disabled since. This uses the private helper method: 2. `get_retina_webp_filepath(string $attachment_file, string $retina_file): string`. This method handles the subtask of getting the correct webp file path based on the attachment's original filepath and the retina image's filename. 3. `remove_imagify_retina_data(int $media_id, string $retina_file): void` will purge optimization data imagify uses to track the status of retina images it has optimized. Two entries have to be checked and removed for each retina image size that's been deleted: the optimization data generated when we optimized the @2x image Perfect Images created, and the @2x@imagify-webp data for the webp version (if any) that Imagify created in connection with that retina size. This uses the private helper method: 4. `get_retina_imagify_data_size_names(array $sizes, string $origina_size_name): array`. This method compares the sizes information (formatted per `wp_get_attachment_metadata()` to the original filename of an attachment that included a retina image size, and gives us an array of all the related size names that might be present in Imagify's optimization data for the attachment.
Configuration menu - View commit details
-
Copy full SHA for 1063b72 - Browse repository at this point
Copy the full SHA 1063b72View commit details -
Add re-optimization of images after regeneration
Adds a method to restore a full-size image from the backed up original. Adds a method to replace back the previously optimized full-size image after image regeneration. Adds a method to send regenerated images to the queue for re-optimization. We also hook the restore/replace before and after the generation of retina sizes to insure that the original is being used to generate the retinas as well.
Configuration menu - View commit details
-
Copy full SHA for a4e0adb - Browse repository at this point
Copy the full SHA a4e0adbView commit details
Commits on Feb 7, 2022
-
These were added back in on 4ffeb21 just in case. It turns out we don't need them any more.
Configuration menu - View commit details
-
Copy full SHA for 33c212f - Browse repository at this point
Copy the full SHA 33c212fView commit details -
All Perfect Images functionality is handled in the PerfectImages class now. The PerfectImagesCore is dead code.
Configuration menu - View commit details
-
Copy full SHA for 3ee9a92 - Browse repository at this point
Copy the full SHA 3ee9a92View commit details -
Remove PerfectImagesCore from main class
Also, cleans up some phpcs spacing and comment formatting.
Configuration menu - View commit details
-
Copy full SHA for 773e60e - Browse repository at this point
Copy the full SHA 773e60eView commit details -
Configuration menu - View commit details
-
Copy full SHA for 1107dc0 - Browse repository at this point
Copy the full SHA 1107dc0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 05f3d8a - Browse repository at this point
Copy the full SHA 05f3d8aView commit details -
Configuration menu - View commit details
-
Copy full SHA for 830c391 - Browse repository at this point
Copy the full SHA 830c391View commit details
Commits on Feb 8, 2022
-
Configuration menu - View commit details
-
Copy full SHA for c8cc135 - Browse repository at this point
Copy the full SHA c8cc135View commit details -
Use array_keys to get size names directly
We're not going to use the related data in this case. Just get the keys and eliminate the unused variable inside foreach.
Configuration menu - View commit details
-
Copy full SHA for e4eff0d - Browse repository at this point
Copy the full SHA e4eff0dView commit details -
Extract can_restore_original() method
The cyclomatic complexity (and readability) of `restore_originally_uploaded_image()` was 10. All of that is due to checking the various conditions before doing the restore. This extracts all the checking to a helper method.
Configuration menu - View commit details
-
Copy full SHA for a9ab001 - Browse repository at this point
Copy the full SHA a9ab001View commit details -
Extract add_webp_sizes() to helper method
Refactors the process for getting the needed webp sizes for optimization to it's own method.
Configuration menu - View commit details
-
Copy full SHA for 142fd83 - Browse repository at this point
Copy the full SHA 142fd83View commit details
Commits on Feb 11, 2022
-
Check for new upload before doing retina process
For new uploads, we're going optimize everything after all the other things run their stuff. In this case we don't want to start a proces for this media now -- doing so will "Lock" the media when the full process tries to run in a few moments, and while retinas will be processed nothing else will be included!
Configuration menu - View commit details
-
Copy full SHA for 8fc613f - Browse repository at this point
Copy the full SHA 8fc613fView commit details