Changeset 57687
- Timestamp:
- 02/21/2024 07:25:18 PM (10 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/customize/class-wp-customize-media-control.php
r57524 r57687 100 100 'url' => $this->setting->default, 101 101 'type' => $type, 102 'icon' => wp_mime_type_icon( $type ),102 'icon' => wp_mime_type_icon( $type, '.svg' ), 103 103 'title' => wp_basename( $this->setting->default ), 104 104 ); -
trunk/src/wp-includes/deprecated.php
r57524 r57687 1911 1911 $src = wp_get_attachment_url( $post->ID ); 1912 1912 $src_file = & $file; 1913 } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {1913 } elseif ( $src = wp_mime_type_icon( $post->ID, '.svg' ) ) { 1914 1914 // No thumb, no image. We'll look for a mime-related icon instead. 1915 1915 -
trunk/src/wp-includes/media.php
r57597 r57687 973 973 974 974 if ( $icon ) { 975 $src = wp_mime_type_icon( $attachment_id );975 $src = wp_mime_type_icon( $attachment_id, '.svg' ); 976 976 977 977 if ( $src ) { … … 979 979 $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' ); 980 980 981 $src_file 981 $src_file = $icon_dir . '/' . wp_basename( $src ); 982 982 list( $width, $height ) = wp_getimagesize( $src_file ); 983 $ext = strtolower( substr( $src_file, -4 ) ); 984 if ( '.svg' === $ext ) { 985 // SVG does not have true dimensions, so this assigns width and height directly. 986 $width = 48; 987 $height = 64; 988 } else { 989 list( $width, $height ) = wp_getimagesize( $src_file ); 990 } 983 991 } 984 992 } … … 3068 3076 $track['thumb'] = compact( 'src', 'width', 'height' ); 3069 3077 } else { 3070 $src = wp_mime_type_icon( $attachment->ID );3078 $src = wp_mime_type_icon( $attachment->ID, '.svg' ); 3071 3079 $width = 48; 3072 3080 $height = 64; … … 4340 4348 'type' => $type, 4341 4349 'subtype' => $subtype, 4342 'icon' => wp_mime_type_icon( $attachment->ID ),4350 'icon' => wp_mime_type_icon( $attachment->ID, '.svg' ), 4343 4351 'dateFormatted' => mysql2date( __( 'F j, Y' ), $attachment->post_date ), 4344 4352 'nonces' => array( … … 4511 4519 $response['thumb'] = compact( 'src', 'width', 'height' ); 4512 4520 } else { 4513 $src = wp_mime_type_icon( $attachment->ID );4521 $src = wp_mime_type_icon( $attachment->ID, '.svg' ); 4514 4522 $width = 48; 4515 4523 $height = 64; -
trunk/src/wp-includes/post.php
r57644 r57687 6804 6804 * @since 2.1.0 6805 6805 * 6806 * @param string|int $mime MIME type or attachment ID. 6806 * @param string|int $mime MIME type or attachment ID. 6807 * @param string $preferred_ext File format to prefer in return. Default .png. 6807 6808 * @return string|false Icon, false otherwise. 6808 6809 */ 6809 function wp_mime_type_icon( $mime = 0 ) {6810 function wp_mime_type_icon( $mime = 0, $preferred_ext = '.png' ) { 6810 6811 if ( ! is_numeric( $mime ) ) { 6811 6812 $icon = wp_cache_get( "mime_type_icon_$mime" ); … … 6886 6887 continue; 6887 6888 } 6888 $icon_files[ "$dir/$file" ] = "$uri/$file"; 6889 if ( $ext === $preferred_ext ) { 6890 $icon_files[ "$dir/$file" ] = "$uri/$file"; 6891 } 6889 6892 } 6890 6893 closedir( $dh ); -
trunk/tests/phpunit/tests/media.php
r57019 r57687 400 400 // #21963, there will be a GUID always, so there will be a URL. 401 401 $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'] ); 403 403 404 404 // Fake a mime.
Note: See TracChangeset
for help on using the changeset viewer.