Make WordPress Core

Changeset 57846 for branches/6.5


Ignore:
Timestamp:
03/15/2024 08:56:20 PM (2 years 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 dglingren, sabernhardt, swissspidy, sabernhardt, antpb, joedolson.
Reviewed by swissspidy.
Merges [57845] to the 6.5 branch.
Fixes #60740.

Location:
branches/6.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/src/wp-includes/post.php

    r57701 r57846  
    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.