humanmade / humanmade/altis-cli
Delete and purge media command
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 1
- Avg merge
- 7d 9h
- Merged PRs (30d)
- 3
Description
A task was encountered that involves deleting an old image from the site due to copyright issues. While the image was removed from the post, the asset remains accessible via its direct URL.
To completely remove the asset, the following steps are necessary:
## 1. Delete the Asset from S3
- List all files in the containing folder to verify the asset's location:
```bash
wp s3-uploads ls uploads/year/month
```
- Check for any WordPress generated image sizes that may also need deletion.
- Delete the file using the command:
```bash
wp s3-uploads rm uploads/year/month/image.jpg
```
**Note:** There is a bug where a success message is displayed even if the file was not found. Verification of the deletion can be done by listing the files again.
## 2. Purge the Asset from CDN Cache
- Open the shell:
```bash
wp shell
```
- Purge the CDN cache for both `/uploads/` and `/tachyon/` paths. Use a wildcard `*` at the end of the tachyon path to purge all generated images:
```php
Altis\Cloud\purge_cdn_paths([ '/uploads/year/month/image.jpg', '/tachyon/year/month/image.jpg*' ]);
```
## Suggestion for Automation
To streamline this process, it is suggested to create a command that automates these steps. This command could encapsulate the listing, deletion, and CDN purging into a single execution, reducing the potential for human error and improving efficiency.
Please consider implementing this automation to simplify the workflow for future instances.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.