@@ -869,6 +869,50 @@ Feature: Regenerate WordPress attachments
869869 {SCALED_CHECKSUM}
870870 """
871871
872+ @require-wp-5.3
873+ Scenario : Regenerating only-missing sizes on WP 5.3+ uses wp_update_image_subsizes and does not recreate the scaled version
874+ Given download:
875+ | path | url |
876+ | {CACHE_DIR }/large -image .jpg | http ://wp -cli .org /behat -data /large -image .jpg |
877+ And I run `wp option update uploads_use_yearmonth_folders 0`
878+
879+ When I run `wp media import {CACHE_DIR}/large-image.jpg --title="My imported attachment" --porcelain`
880+ Then save STDOUT as {ATTACHMENT_ID}
881+ And the wp-content/uploads/large-image-scaled.jpg file should exist
882+ And the wp-content/uploads/large-image-300x225.jpg file should exist
883+
884+ # Save a checksum of the scaled image before any regeneration.
885+ When I run `md5sum wp-content/uploads/large-image-scaled.jpg`
886+ Then save STDOUT as {SCALED_CHECKSUM}
887+
888+ # Add a new image size and a filter that produces drastically different output quality
889+ # if the scaled image were regenerated from scratch.
890+ Given a wp-content/mu-plugins/media-settings.php file:
891+ """
892+ <?php
893+ add_action( 'after_setup_theme', function(){
894+ add_image_size( 'test1', 400, 300, true );
895+ });
896+ // If the scaled image is regenerated, its checksum will differ because of this low quality.
897+ add_filter( 'jpeg_quality', function() { return 1; } );
898+ """
899+
900+ When I run `wp media regenerate {ATTACHMENT_ID} --only-missing --yes`
901+ Then STDOUT should contain:
902+ """
903+ 1/1 Regenerated thumbnails for "My imported attachment"
904+ """
905+ And the wp-content/uploads/large-image-400x300.jpg file should exist
906+
907+ # Verify the scaled image was NOT regenerated by wp_update_image_subsizes()
908+ # (checksum should be unchanged, because wp_update_image_subsizes() only generates
909+ # the missing sub-sizes and does not recreate the scaled/attached file).
910+ When I run `md5sum wp-content/uploads/large-image-scaled.jpg`
911+ Then STDOUT should be:
912+ """
913+ {SCALED_CHECKSUM}
914+ """
915+
872916 @require-wp-4.7.3 @require-extension-imagick
873917 Scenario : Regenerate a specific image size for a PDF attachment
874918 Given download:
0 commit comments