Skip to content

Allow multiple image sizes for regeneration via repeated --image_size flags#231

Merged
swissspidy merged 9 commits intomainfrom
copilot/allow-multiple-image-sizes
Mar 10, 2026
Merged

Allow multiple image sizes for regeneration via repeated --image_size flags#231
swissspidy merged 9 commits intomainfrom
copilot/allow-multiple-image-sizes

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

  • Switch --image_size to repeating flag syntax ([--image_size=<image_size>...])
  • Update parsing to handle both single string (WP-CLI 2.x) and array (WP-CLI 3.x)
  • Update docblock examples and Behat tests to use --image_size=large --image_size=medium
  • Fix test: "thumbnail" → "thumbnails" for the no-regeneration message with multiple sizes
  • Fix log message: update_attachment_metadata_for_image_size() returns string[] of actually-regenerated sizes; "Regenerated" message uses that list instead of all requested sizes
  • Extract get_image_sizes_description() private helper and use Utils\pluralize() internally to eliminate both duplicated string-building logic and the manual plural noun parameter
Original prompt

This section details on the original issue you should resolve

<issue_title>Allow multiple image_sizes for regeneration</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing

I had the case that I needed to regenerate 2 image sizes, or rather 1 newly added and 1 existing image size.
To solve this I had to run wp media regenerate --image_size=new_image_size and wp media regenerate --image_size=updated_image_size

Since I am talking about a multisite with 6 sites that we want to update, and each has at least 10k attachments, running the two commands does not seem to be efficient.

Describe the solution you'd like

I would love to be able to run either:

Enhancing the existing --image_size to allow single or multiple image sizes)
wp media regenerate --image_size=new_image_size,updated_image_size

or

Introducing a new --image_sizes that will accept multiple, in order to keep the grammar correct.
wp media regenerate --image_sizes=new_image_size,updated_image_size

Note: I'm happy to propose a PR, I'd just need a heads up if you think it's a good addition and which of the two suggested routes to take. I might need help updating the related unit tests.</issue_description>

<agent_instructions>This is now possible, see wp-cli/wp-cli#6198</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@swissspidy Related:

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@github-actions github-actions bot added command:media Related to 'media' command command:media-regenerate Related to 'media regenerate' command scope:testing Related to testing labels Mar 9, 2026
…ge_size

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Allow multiple image sizes for regeneration Allow multiple image sizes for regeneration via comma-separated --image_size Mar 9, 2026
@swissspidy

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Copilot AI changed the title Allow multiple image sizes for regeneration via comma-separated --image_size Allow multiple image sizes for regeneration via repeated --image_size flags Mar 10, 2026
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review March 10, 2026 11:31
@swissspidy swissspidy requested a review from a team as a code owner March 10, 2026 11:31
Copilot AI review requested due to automatic review settings March 10, 2026 11:31
@swissspidy

This comment was marked as resolved.

This comment was marked as resolved.

…ted sizes

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

…ing-building logic

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

…ual plural_noun parameter

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy added this to the 2.2.6 milestone Mar 10, 2026
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 94.52055% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Media_Command.php 94.52% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy merged commit 93627bb into main Mar 10, 2026
60 checks passed
@swissspidy swissspidy deleted the copilot/allow-multiple-image-sizes branch March 10, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:media Related to 'media' command command:media-regenerate Related to 'media regenerate' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow multiple image_sizes for regeneration

3 participants