Make WordPress Core

Ticket #31352: 31352.follow.diff

File 31352.follow.diff, 4.5 KB (added by joedolson, 11 months ago)

Handle list view; update tests

  • src/wp-includes/media.php

     
    978978                                /** This filter is documented in wp-includes/post.php */
    979979                                $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );
    980980
    981                                 $src_file               = $icon_dir . '/' . wp_basename( $src );
    982                                 list( $width, $height ) = wp_getimagesize( $src_file );
     981                                $src_file = $icon_dir . '/' . wp_basename( $src );
     982                                $ext      = strtolower( substr( $src_file, -4 ) );
     983                                if ( '.svg' === $ext ) {
     984                                        // SVG doesn't have true dimensions, so we assign width and height directly.
     985                                        $width  = 48;
     986                                        $height = 64;
     987                                } else {
     988                                        list( $width, $height ) = wp_getimagesize( $src_file );
     989                                }
    983990                        }
    984991                }
    985992
  • tests/phpunit/tests/media.php

     
    399399                $this->assertSame( '', $prepped['subtype'] );
    400400                // #21963, there will be a GUID always, so there will be a URL.
    401401                $this->assertNotEquals( '', $prepped['url'] );
    402                 $this->assertSame( site_url( 'wp-includes/images/media/default.png' ), $prepped['icon'] );
     402                $this->assertSame( site_url( 'wp-includes/images/media/default.svg' ), $prepped['icon'] );
    403403
    404404                // Fake a mime.
    405405                $post->post_mime_type = 'image/jpeg';
  • tests/phpunit/tests/post/attachments.php

     
    508508        public function test_wp_mime_type_icon() {
    509509                $icon = wp_mime_type_icon();
    510510
    511                 $this->assertStringContainsString( 'images/media/default.png', $icon );
     511                $this->assertStringContainsString( 'images/media/default.svg', $icon );
    512512        }
    513513
    514514        /**
     
    517517        public function test_wp_mime_type_icon_video() {
    518518                $icon = wp_mime_type_icon( 'video/mp4' );
    519519
    520                 $this->assertStringContainsString( 'images/media/video.png', $icon );
     520                $this->assertStringContainsString( 'images/media/video.svg', $icon );
    521521        }
    522522}