WordPress.org

Make WordPress Core

Ticket #34109: 34109.diff

File 34109.diff, 1.4 KB (added by joemcgill, 4 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 89b88df..9783b61 100644
    function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon 
    766766                        $image = array( $src, $width, $height );
    767767                }
    768768        }
     769
     770        // Force HTTPS schemes in the admin when force_ssl_admin() is true.
     771        if ( $image && is_admin() && force_ssl_admin() ) {
     772                $image[0] = set_url_scheme( $image[0], 'https' );
     773        }
     774
    769775        /**
    770776         * Filter the image src result.
    771777         *
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index 3da75a0..cbf3d23 100644
    EOF; 
    11331133                // Intermediate sized GIFs should not include the full size in the srcset.
    11341134                $this->assertFalse( strpos( wp_calculate_image_srcset( $size_array, $large_src, $image_meta ), $full_src ) );
    11351135        }
     1136
     1137        /**
     1138         * @ticket 34109
     1139         */
     1140        function test_wp_get_attachment_image_src_https_admin() {
     1141                // Save our starting setup.
     1142                $force_ssl_admin = force_ssl_admin();
     1143                $curent_screen = get_current_screen();
     1144
     1145                force_ssl_admin( true );
     1146                set_current_screen( 'dashboard' );
     1147
     1148                $image = wp_get_attachment_image_src( self::$large_id );
     1149
     1150                $this->assertSame( $image[0], set_url_scheme( $image[0], 'https' ) );
     1151
     1152                // Leave things as we found them.
     1153                force_ssl_admin( $force_ssl_admin );
     1154                $GLOBALS['current_screen'] = $curent_screen;
     1155        }
    11361156}