Skip to content

Regenerate with --image_size deletes all other sizes from postmeta #130

@goaround

Description

@goaround

Bug Report

--- ✅ If you are in the correct location now... --->

Describe the current, buggy behavior

I changed the height/width of an image size and tried to regenerate only the thumbnails for this specific size with--image_size=medium Here my full command:

wp media regenerate --image_size=medium --skip-delete --only-missing

After the regeneration, the REST API showed only medium under sizes. I checked the postmeta database table for the _wp_attachment_metadata and it seems like, that _wp_attachment_metadata now only contains the regenerated size, all other are gone:

 'sizes' => 
  array (
    'medium' => 
    array (
      'file' => 'Lissabon-Strassenbahnen-300x214.jpg',
      'width' => 300,
      'height' => 214,
      'mime-type' => 'image/jpeg',
    ),
  ),

If I run the command without --image_size its fine again:

wp media regenerate --skip-delete --only-missing

'sizes' => 
  array (
    'medium' => 
    array (
      'file' => 'Lissabon-Strassenbahnen-300x214.jpg',
      'width' => 300,
      'height' => 214,
      'mime-type' => 'image/jpeg',
    ),
    'thumbnail' => 
    array (
      'file' => 'Lissabon-Strassenbahnen-150x150.jpg',
      'width' => 150,
      'height' => 150,
      'mime-type' => 'image/jpeg',
    ),
    'medium_large' => 
    array (
      'file' => 'Lissabon-Strassenbahnen-768x548.jpg',
      'width' => 768,
      'height' => 548,
      'mime-type' => 'image/jpeg',
    ),
    'logo' => 
    array (
      'file' => 'Lissabon-Strassenbahnen-180x128.jpg',
      'width' => 180,
      'height' => 128,
      'mime-type' => 'image/jpeg',
    ),
  ),

Describe how other contributors can replicate this bug

  1. Upload an Image
  2. Change the size settings for medium in WordPress
  3. Regenrate the thumbnails with --image_size=medium
  4. Check postmeta table for _wp_attachment_metadata

Describe what you would expect as the correct outcome

I would expect, that all other sizes would still be in the metadata, only the specific size changed

Let us know what environment you are running this on

OS:	Darwin 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
Shell:	/bin/zsh
PHP binary:	/usr/local/Cellar/php/7.4.0/bin/php
PHP version:	7.4.0
php.ini used:	/usr/local/etc/php/7.4/php.ini
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/Users/johanneskinast/Valet Sites/travel-dealz
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	2.4.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions