WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/04/2015 12:21:23 AM (5 years ago)
Author:
azaozz
Message:

Responsive images:

  • Fix _wp_upload_dir_baseurl() to cache by blog_id.
  • Replace path_join() with trailingslashit(), it's much faster.
  • Rename $image_url to $image_src for consistency (used at about 50 other places).
  • Couple of tests fixes.

See #34430.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r35479 r35498  
    786786        foreach ( $sizes as $size ) {
    787787            $size_array = $this->_get_image_size_array_from_name( $size );
    788             $image_url = wp_get_attachment_image_url( self::$large_id, $size );
     788            $image_url = wp_get_attachment_image_url( $id, $size );
    789789            $this->assertSame( $expected, wp_calculate_image_srcset( $image_url, $size_array, $image_meta ) );
    790790        }
     791
     792        // Remove the attachment
     793        wp_delete_attachment( $id );
    791794
    792795        // Leave the uploads option the way you found it.
     
    801804        // Start by getting the attachment metadata.
    802805        $image_meta = wp_get_attachment_metadata( self::$large_id );
    803         $image_url = wp_get_attachment_image_url( self::$large_id );
     806        $image_url = wp_get_attachment_image_url( self::$large_id, 'medium' );
    804807        $size_array = $this->_get_image_size_array_from_name( 'medium' );
    805808
     
    807810        $hash = 'e' . time() . rand(100, 999);
    808811
     812        $filename_base = basename( $image_meta['file'], '.png' );
     813
     814        // Add the hash to the image URL
     815        $image_url = str_replace( $filename_base, $filename_base . '-' . $hash, $image_url );
     816
    809817        // Replace file paths for full and medium sizes with hashed versions.
    810         $filename_base = basename( $image_meta['file'], '.png' );
    811818        $image_meta['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['file'] );
    812819        $image_meta['sizes']['medium']['file'] = str_replace( $filename_base, $filename_base . '-' . $hash, $image_meta['sizes']['medium']['file'] );
Note: See TracChangeset for help on using the changeset viewer.