I changed the "medium" image size in the WordPress media settings from 360x360px to 400x400px and ran the following command:
wp media regenerate --missing-only
The images were regenerated, but some were skipped as "No thumbnail regeneration needed". I later discovered that the meta data in the image attachments for those that were skipped still referenced the 360px version of the "medium" sized image. I identified all affected image attachments and then ran:
wp media regenerate [attachment-ids]
This successfully updated the attachment meta and removed the reference to the 360px version of the image. I believe this occurred on images that were <= 400px.
It appears that if the command sees that the original image is the same size or less than the target, it is skipped but in doing so the meta is not updated to reference the original image.
Describe how other contributors can replicate this bug
Set medium size images to 360 x 360 in WordPress settings
Upload an image of size 400 x 400
Change medium size images to 400 x 400 in WordPress settings
Run wp media regenerate --missing-only
Image is skipped, meta for medium refers to the 360x360 version of the image
Example meta (note 360px image still referenced as "medium" size):
Bug Report
Describe the current, buggy behavior
I changed the "medium" image size in the WordPress media settings from 360x360px to 400x400px and ran the following command:
wp media regenerate --missing-only
The images were regenerated, but some were skipped as "No thumbnail regeneration needed". I later discovered that the meta data in the image attachments for those that were skipped still referenced the 360px version of the "medium" sized image. I identified all affected image attachments and then ran:
wp media regenerate [attachment-ids]
This successfully updated the attachment meta and removed the reference to the 360px version of the image. I believe this occurred on images that were <= 400px.
It appears that if the command sees that the original image is the same size or less than the target, it is skipped but in doing so the meta is not updated to reference the original image.
Describe how other contributors can replicate this bug
wp media regenerate --missing-only
Example meta (note 360px image still referenced as "medium" size):
Additionally, the old 360px medium size image file is not deleted from the filesystem.
Example meta after running
wp media regenerate [attachment-id]
on affected image (note 360px version removed from meta and filesystem):Describe what you would expect as the correct outcome
Image meta should be updated.
Let us know what environment you are running this on