Improve cleanup of unknown or unregistered image sizes and add logging

Open
#217 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
wordpress
Domain
cli

Research direction

No files, tests, or entry points are named. Start by locating the image cleanup routine and its attachment metadata handling, then define the affected files and tests from the existing behavior. Done means unknown, unregistered, intermediate, and matching .webp files are handled as specified, with deleted and generated thumbnails logged.

Written by the indexing model from the issue text.

Description

command:media-regenerate

Feature Request

Describe your use case and the problem you are facing

When cleaning up images, some leftovers remain - specifically those with unknown or unregistered sizes.

Additionally, certain plugins, such as EWWW Image Optimizer, generate extra .webp versions of existing images. These should be removed as part of the cleanup process.

Currently, there is no logging of deleted or generated files, which makes it difficult to track changes or verify cleanup results.

Describe the solution you'd like

Introduce a more thorough cleanup routine that:

  • Deletes intermediate image files and their .webp counterparts, if they exist.
  • Scans the attachment directory and removes files that:
    • Are not registered in metadata.
    • Do not match the expected thumbnail naming convention.
    • Are not legitimate thumbnails.
  • Logs all deleted and generated thumbnails.
Dominant language
Gherkin
Stars
47
Forks
42
Avg merge
2h 30m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wp-cli/media-command

All issues in wp-cli/media-command

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.