ThemeFuse / Unyson-Backups-Extension

Backup & Demo Content - This extension lets you create an automated backup schedule, import demo content or even create a demo content archive for migration purposes.
http://manual.unyson.io/en/latest/extension/backups/
10 stars 17 forks source link

feat($images): add option for removing old image sizes #52

Closed andreiglingeanu closed 7 years ago

andreiglingeanu commented 7 years ago

This pull request introduces an option to delete remove the old attachment sizes, which are no longer used. Highly inspired by --skip-delete cli flag for wp media regenerate command. This option is disabled by default and can be enabled ONLY after rigorous testing!

That is achieved by removing all the existing attachment sizes right before starting the regeneration phase of the task.


How to test this feature:

  1. Open framework/extensions/backups/includes/module/tasks/type/class-fw-ext-backups-task-type-image-sizes-restore.php
  2. Change the array('remove_old_files' => false) to be like that: array('remove_old_files' => true)
  3. Apply a new demo content and see how images are regenerated

By default this does nothing and we can turn it on in some useful scenarios. The implementation is inspired from https://github.com/wp-cli/wp-cli.

cc. @ViorelEremia @danyj

andreiglingeanu commented 7 years ago

The code is robust enough to be merged and does not introduce any possible complications. Feel free to raise any issues or questions with it and please do it :)

danyj commented 7 years ago

can turn it on in some useful scenarios.

like?

andreiglingeanu commented 7 years ago

@danyj Like launching that particular task as part of another task collection :) In order to manually regenerate thumbnails in background (without everything else that comes with applying a demo content), without any plugins or third-party dependencies.