Making WordPress.org


Ignore:
Timestamp:
03/17/2023 03:48:02 AM (15 months ago)
Author:
dd32
Message:

Plugin Directory: When a plugin has multiple formats of an image asset (svg, png, jpg) prefer them in that order.

See https://wordpress.slack.com/archives/C02QB8GMM/p1678987204746449.
See #6627.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r12475 r12477  
    568568        if ( ! $assets ) {
    569569            return false;
     570        }
     571
     572        // Sort them if needed, svg > png > jpg
     573        if ( count( $assets ) > 1 ) {
     574            uasort( $assets, function( $a, $b ) {
     575                // Thankfully the extensions are alphabetical, so let's just sort by that.
     576                $a_ext = strtolower( pathinfo( $a['filename'], PATHINFO_EXTENSION ) );
     577                $b_ext = strtolower( pathinfo( $b['filename'], PATHINFO_EXTENSION ) );
     578
     579                return $b_ext <=> $a_ext;
     580            } );
    570581        }
    571582
Note: See TracChangeset for help on using the changeset viewer.