Make WordPress Core

Ticket #34109: 34109.2.diff

File 34109.2.diff, 2.6 KB (added by jeremyfelt, 9 years ago)
  • src/wp-admin/includes/image-edit.php

     
    152152        </div>
    153153
    154154        <figure class="imgedit-thumbnail-preview">
    155                 <img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" />
     155                <img src="<?php echo set_url_scheme( $thumb['url'] ); ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" />
    156156                <figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption>
    157157        </figure>
    158158
     
    870870                        // Check if it's an image edit from attachment edit screen
    871871                        if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' == $_REQUEST['context'] ) {
    872872                                $thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
    873                                 $return->thumbnail = $thumb_url[0];
     873                                $return->thumbnail = set_url_scheme( $thumb_url[0] );
    874874                        } else {
    875875                                $file_url = wp_get_attachment_url($post_id);
    876876                                if ( ! empty( $meta['sizes']['thumbnail'] ) && $thumb = $meta['sizes']['thumbnail'] ) {
  • src/wp-includes/media.php

     
    766766                        $image = array( $src, $width, $height );
    767767                }
    768768        }
     769
     770        // Change the scheme in the admin to match when either is_ssl() or force_ssl_admin().
     771        if ( $image && is_admin() ) {
     772                $image[0] = set_url_scheme( $image[0], 'admin' );
     773        }
     774
    769775        /**
    770776         * Filter the image src result.
    771777         *
  • tests/phpunit/tests/media.php

     
    14081408
    14091409                $this->assertSame( $expected, $actual );
    14101410        }
     1411
     1412        /**
     1413         * @ticket 34109
     1414         */
     1415        function test_wp_get_attachment_image_src_https_admin() {
     1416                // Save our starting setup.
     1417                $force_ssl_admin = force_ssl_admin();
     1418                $curent_screen = get_current_screen();
     1419
     1420                force_ssl_admin( true );
     1421                set_current_screen( 'dashboard' );
     1422
     1423                $image = wp_get_attachment_image_src( self::$large_id );
     1424
     1425                $this->assertSame( $image[0], set_url_scheme( $image[0], 'https' ) );
     1426
     1427                // Leave things as we found them.
     1428                force_ssl_admin( $force_ssl_admin );
     1429                $GLOBALS['current_screen'] = $curent_screen;
     1430        }
    14111431}