WordPress.org

Make WordPress Core

Ticket #39883: 39883.2.diff

File 39883.2.diff, 1000 bytes (added by joemcgill, 3 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 19eba00a6a..e42e54a083 100644
    function image_hwstring( $width, $height ) { 
    183183 *                     the image is an intermediate size. False on failure.
    184184 */
    185185function image_downsize( $id, $size = 'medium' ) {
    186         $is_image = wp_attachment_is_image( $id );
     186        $is_image = false;
     187
     188        /*
     189         * Check attachment to see if we support returning image attributes for
     190         * this type. This is to avoid the 'image_downsize' filter and making
     191         * unneeded DB queries when the type is unsupported.
     192         */
     193        $supported = false;
     194        $supported_types = array( 'image', 'pdf' );
     195
     196        foreach ( $supported_types as $type ) {
     197                $supported = wp_attachment_is( $type, $id );
     198                if ( $supported ) {
     199                        $is_image = ( 'image' === $type );
     200                        break;
     201                }
     202        }
     203
     204        if ( ! $supported ) {
     205                return false;
     206        }
    187207
    188208        /**
    189209         * Filters whether to preempt the output of image_downsize().