Make WordPress Core

Changeset 57845


Ignore:
Timestamp:
03/15/2024 04:35:18 PM (9 months ago)
Author:
joedolson
Message:

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.

File:
1 edited

Legend:

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

    r57701 r57845  
    68696869            $dirs       = apply_filters( 'icon_dirs', array( $icon_dir => $icon_dir_uri ) );
    68706870            $icon_files = array();
     6871            $all_icons  = array();
    68716872            while ( $dirs ) {
    68726873                $keys = array_keys( $dirs );
     
    68886889                            continue;
    68896890                        }
     6891                        $all_icons[ "$dir/$file" ] = "$uri/$file";
    68906892                        if ( $ext === $preferred_ext ) {
    68916893                            $icon_files[ "$dir/$file" ] = "$uri/$file";
     
    68946896                    closedir( $dh );
    68956897                }
     6898            }
     6899            // If directory only contained icons of a non-preferred format, return those.
     6900            if ( empty( $icon_files ) ) {
     6901                $icon_files = $all_icons;
    68966902            }
    68976903            wp_cache_add( 'icon_files', $icon_files, 'default', 600 );
Note: See TracChangeset for help on using the changeset viewer.