Skip to content

socialkandy/cli-media-cleanup

Repository files navigation

socialkandy/wp-cli-media-cleanup

Build Status

Quick links: Using | Installing | Contributing | Support

Using

This package implements the following commands:

wp media cleanup

Clean all invalid attachments and files from your site.

wp media cleanup [--dry-run] [--yes] [--files-only] [--attachments-only]

Analyzes all files in your wp-uploads folder looking for references in attachments metadata. And it also checks if all attachments files exists.

OPTIONS

[--dry-run]
	Only search and analyze, but won't delete anything.
[--yes]
	Answer yes to confirmation messages.
[--files-only]
	Search and delete only invalid files.
[--attachments-only]
	Search and delete only invalid attachments.

EXAMPLES

$ wp media cleanup
Scanning attachments...
No file found for attachment #1
No file found for attachment #2
...
No file found for attachment #12
You have 12 attachments with no file associated.
Are you sure you want to delete 12 invalid attachments? [y/n] y
Success: Deleted 12 invalid attachments.
Scanning uploads folder: /srv/www/site/wp-content/uploads/
You have 230 files in total.
No attachment found for 2018/01/file-01.jpg
No attachment found for 2018/01/file-02.jpg
...
No attachment found for other/folder/file-72.jpg
There are 158 files with valid attachments.
There are 72 files with no attachment associated.
Are you sure you want to delete 72 invalid files? [y/n] y
Success: Deleted 72 invalid files.

$ wp media cleanup --attachments-only --dry-run
Scanning attachments...
No file found for attachment #1
No file found for attachment #2
...
No file found for attachment #12
You have 12 attachments with no file associated.

$ wp media cleanup --attachments-only --yes
Scanning attachments...
No file found for attachment #1
No file found for attachment #2
...
No file found for attachment #12
You have 12 attachments with no file associated.
Success: Deleted 12 invalid attachments.

Installing

Installing this package requires WP-CLI v1.1.0 or greater. Update to the latest stable release with wp cli update.

Once you've done so, you can install this package with:

wp package install git@github.com:socialkandy/wp-cli-media-cleanup.git

Contributing

We appreciate you taking the initiative to contribute to this project.

Contributing isn’t limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

For a more thorough introduction, check out WP-CLI's guide to contributing. This package follows those policy and guidelines.

Reporting a bug

Think you’ve found a bug? We’d love for you to help us get it fixed.

Before you create a new issue, you should search existing issues to see if there’s an existing resolution to it, or if it’s already been fixed in a newer version.

Once you’ve done a bit of searching and discovered there isn’t an open or fixed issue for your bug, please create a new issue. Include as much detail as you can, and clear steps to reproduce if possible. For more guidance, review our bug report documentation.

Creating a pull request

Want to contribute a new feature? Please first open a new issue to discuss whether the feature is a good fit for the project.

Once you've decided to commit the time to seeing your pull request through, please follow our guidelines for creating a pull request to make sure it's a pleasant experience. See "Setting up" for details specific to working on this package locally.

Support

Github issues aren't for general support questions, but there are other venues you can try: http://wp-cli.org/#support

This README.md is generated dynamically from the project's codebase using wp scaffold package-readme (doc). To suggest changes, please submit a pull request against the corresponding part of the codebase.

Releases

No releases published

Packages

No packages published

Languages