Media: Fall back to available icons if SVG media icons not found.

Follow up to [57687]. If no icons of the preferred type are available, then the icon array should return the collection of valid icons found, rather than an empty array.

Props sabernhardt, swissspidy, sabernhardt, antpb, joedolson.
Fixes #60740.
Built from https://develop.svn.wordpress.org/trunk@57845


git-svn-id: http://core.svn.wordpress.org/trunk@57346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2024-03-15 16:37:11 +00:00
parent 5a59a56abc
commit c6c7d5080a
2 changed files with 7 additions and 1 deletions

View File

@ -6868,6 +6868,7 @@ function wp_mime_type_icon( $mime = 0, $preferred_ext = '.png' ) {
*/
$dirs = apply_filters( 'icon_dirs', array( $icon_dir => $icon_dir_uri ) );
$icon_files = array();
$all_icons = array();
while ( $dirs ) {
$keys = array_keys( $dirs );
$dir = array_shift( $keys );
@ -6887,6 +6888,7 @@ function wp_mime_type_icon( $mime = 0, $preferred_ext = '.png' ) {
}
continue;
}
$all_icons[ "$dir/$file" ] = "$uri/$file";
if ( $ext === $preferred_ext ) {
$icon_files[ "$dir/$file" ] = "$uri/$file";
}
@ -6894,6 +6896,10 @@ function wp_mime_type_icon( $mime = 0, $preferred_ext = '.png' ) {
closedir( $dh );
}
}
// If directory only contained icons of a non-preferred format, return those.
if ( empty( $icon_files ) ) {
$icon_files = $all_icons;
}
wp_cache_add( 'icon_files', $icon_files, 'default', 600 );
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-57842';
$wp_version = '6.6-alpha-57845';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.