[wp-trac] [WordPress Trac] #28277: Add ability to apply image edits to custom image sizes

WordPress Trac noreply at wordpress.org
Tue Apr 12 11:38:10 UTC 2022


#28277: Add ability to apply image edits to custom image sizes
------------------------------+-----------------------------
 Reporter:  silb3r            |       Owner:  joedolson
     Type:  enhancement       |      Status:  accepted
 Priority:  normal            |   Milestone:  6.0
Component:  Media             |     Version:  4.0
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:  administration
------------------------------+-----------------------------
Changes (by costdev):

 * keywords:  has-patch needs-testing => has-patch commit


Comment:

 == Test Report

 === Environment
 * Server: Apache (Linux)
 * WordPress: 6.0-alpha-52448-src
 * Browser: Chrome 100.0.4896.75
 * OS: Windows 10
 * Theme: Twenty Twenty
 * Plugins:
   * Test 'edit_custom_thumbnail_sizes' filter. 1.0.0

 === Steps
 1. Apply
 [https://core.trac.wordpress.org/attachment/ticket/28277/28277.2.diff
 28277.2.diff].
 2. Add the following to `wp-content/plugins/test-edit-custom-thumbnail-
 sizes/test-edit-custom-thumbnail-sizes.php`:

 {{{#!php
 <?php

 /**
  * Plugin Name: Test 'edit_custom_thumbnail_sizes' filter.
  * Description: A test for the 'edit_custom_thumbnail_sizes' filter.
  * Author:      WordPress Core Contributors
  * Version:     1.0.0
  */

 add_action(
         'after_setup_theme',
         function() {
                 add_image_size( 'my-custom-size', 123, 123 );
                 add_filter( 'edit_custom_thumbnail_sizes', '__return_true'
 );

                 if ( ! is_admin() ) {
                         $latest_image = new WP_Query(
                                 array(
                                         'post_type'      => 'attachment',
                                         'post_status'    => 'any',
                                         'posts_per_page' => 1,
                                 )
                         );
                         echo wp_get_attachment_image(
 $latest_image->posts[0]->ID, 'my-custom-size' );
                         echo wp_get_attachment_image(
 $latest_image->posts[0]->ID, 'thumbnail' );
                 }
         }
 );
 }}}
 3. Navigate to `Plugins > Installed Plugins`.
 4. Activate the `Test 'edit_custom_thumbnail_sizes' filter.` plugin.
 5. Navigate to `Media > Add New`.
 6. Upload a new image.
 7. Click `Edit`.
 8. Click `Edit Image`. See that the `my-custom-size` is shown under the
 `Thumbnail Settings > Apply changes to` section. ✅
 9. Select `my-custom-size` under `Thumbnail Settings > Apply changes to`
 section.
 10. At the top, click the `Flip Vertically` button.
 11. Click `Save`.
 12. Click `Update`.
 13. Navigate to the frontend. See that two images are shown:
   - The `my-custom-size` size, flipped vertically. ✅
   - The `thumbnail` size, not flipped vertically. ✅
 === Results
 1. [https://core.trac.wordpress.org/attachment/ticket/28277/28277.2.diff
 28277.2.diff] works as expected.

 === Notes
 - Adding for `commit` consideration.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/28277#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list