Skip to content

Delete and purge media command #26

@svandragt

Description

@svandragt

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:

    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:

    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:

    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:

    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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions