Make WordPress Core


Ignore:
Timestamp:
07/07/2022 11:30:21 PM (4 years ago)
Author:
azaozz
Message:

Media:

  • Deprecate wp_get_attachment_thumb_file().
  • Make wp_get_attachment_thumb_url() an alias of wp_get_attachment_image_url(). This fixes it to return the proper thumbnail URL and fall back to returning the URL to image_meta['thumb'] if only that exists.

Props: markhowellsmead, mukesh27, csesumonpro, SergeyBiryukov, mikeschroder, killua99, joemcgill, mashukushibiki, mfgmicha, swissspidy, romulodl, nacin, JoshuaAbenazer, wonderboymusic, lonnylot, azaozz.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r53481 r53685  
    239239                $height          = $intermediate['height'];
    240240                $is_intermediate = true;
    241         } elseif ( 'thumbnail' === $size ) {
     241        } elseif ( 'thumbnail' === $size && ! empty( $meta['thumb'] ) && is_string( $meta['thumb'] ) ) {
    242242                // Fall back to the old thumbnail.
    243                 $thumb_file = wp_get_attachment_thumb_file( $id );
    244                 $info       = null;
    245 
    246                 if ( $thumb_file ) {
    247                         $info = wp_getimagesize( $thumb_file );
    248                 }
    249 
    250                 if ( $thumb_file && $info ) {
    251                         $img_url         = str_replace( $img_url_basename, wp_basename( $thumb_file ), $img_url );
    252                         $width           = $info[0];
    253                         $height          = $info[1];
    254                         $is_intermediate = true;
     243                $imagefile = get_attached_file( $id );
     244                $thumbfile = str_replace( wp_basename( $imagefile ), wp_basename( $meta['thumb'] ), $imagefile );
     245
     246                if ( file_exists( $thumbfile ) ) {
     247                        $info = wp_getimagesize( $thumbfile );
     248
     249                        if ( $info ) {
     250                                $img_url         = str_replace( $img_url_basename, wp_basename( $thumbfile ), $img_url );
     251                                $width           = $info[0];
     252                                $height          = $info[1];
     253                                $is_intermediate = true;
     254                        }
    255255                }
    256256        }
Note: See TracChangeset for help on using the changeset viewer.