Make WordPress Core

Ticket #38965: 38965.2.diff

File 38965.2.diff, 1.5 KB (added by joemcgill, 9 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index a3a8088..ba52555 100644
    function wp_prepare_attachment_for_js( $attachment ) { 
    31393139        if ( current_user_can( 'delete_post', $attachment->ID ) )
    31403140                $response['nonces']['delete'] = wp_create_nonce( 'delete-post_' . $attachment->ID );
    31413141
    3142         if ( $meta && ! empty( $meta['sizes'] ) ) {
     3142        if ( $meta && ( 'image' === $type || ! empty( $meta['sizes'] ) ) ) {
    31433143                $sizes = array();
    31443144
    31453145                /** This filter is documented in wp-admin/includes/media.php */
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index 2453a47..d8c28c2 100644
    https://w.org</a>' 
    270270        }
    271271
    272272        /**
     273         * @ticket 38965
     274         */
     275        function test_wp_prepare_attachment_for_js_without_image_sizes() {
     276                // Create the attachement post.
     277                $id = wp_insert_attachment( array(
     278                        'post_title' => 'Attachment Title',
     279                        'post_type' => 'attachment',
     280                        'post_parent' => 0,
     281                        'post_mime_type' => 'image/jpeg',
     282                        'guid' => 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/test-image.jpg',
     283                ) );
     284
     285                // Add attachment metadata without sizes.
     286                wp_update_attachment_metadata( $id, array(
     287                        'width' => 50,
     288                        'height' => 50,
     289                        'file' => 'test-image.jpg',
     290                ) );
     291
     292                $prepped = wp_prepare_attachment_for_js( get_post( $id ) );
     293
     294                $this->assertTrue( isset( $prepped['sizes'] ) );
     295        }
     296
     297        /**
    273298         * @ticket 19067
    274299         * @expectedDeprecated wp_convert_bytes_to_hr
    275300         */