How To Get The File Extension Of Images Having Different Extensions In A Directory?

You could send a HEAD request for the allowed resources until you hit a status 200, cache the results (post meta, an option, whatever), and show the best match.

The allowed banner sizes and formats are:

'banner-1544x500.png',
'banner-772x250.png',
'banner-1544x500.jpg',
'banner-772x250.jpg',

The allowed icon sizes and formats:

'icon.svg',
'icon-256x256.jpg',
'icon-128x128.png',

Sending a HEAD request can be done either by using wp_remote_head() or by using cURL.

So let’s just abstract that away:

namespace Wpse\Http;

interface Remote_Resource
{
    /**
     * @param  string $url
     * @return bool
     */
    public function exists( $url );
}

final class Curl_Remote_Resource implements Remote_Resource
{
    /**
     * @param  string $url
     * @return bool
     */
    public function exists( $url )
    {
        $status = `curl -s -o /dev/null -I -w "%{http_code}" $url`;

        return 200 === (int) $status;
    }
}

Now we need just a class to use that check against the different image variations:

/**
 * Find banners and icon for a plugin hosted on wordpress.org
 *
 *
 * @version 2015.08.09
 * @author  toscho
 * @license MIT
 */
final class Wp_Org_Assets
{
    /**
     * @see https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/
     *
     * @var array
     */
    private $banners = [
        'banner-1544x500.png',
        'banner-772x250.png',
        'banner-1544x500.jpg',
        'banner-772x250.jpg',
    ];
    /**
     * @see https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/
     *
     * @var array
     */
    private $icons = [
        // Do not embed unknown SVG in your HTML. Use the `<img>` element instead!
        'icon.svg',
        'icon-256x256.jpg',
        'icon-128x128.png',
    ];

    /**
     * @var string
     */
    private $url;

    /**
     * @var \Wpse\Http\Remote_Resource
     */
    private $remote;

    /**
     * This constructor is private, use one of the static "named constructors" instead.
     *
     * @see http://verraes.net/2014/06/named-constructors-in-php/
     * @param string                     $slug Plugin slug like "multilingual-press"
     * @param \Wpse\Http\Remote_Resource $remote
     */
    private function __construct( $slug, Remote_Resource $remote )
    {
        $this->url    = "https://plugins.svn.wordpress.org/$slug/assets";
        $this->remote = $remote;
    }

    /**
     * @param string                     $slug Plugin slug like "multilingual-press"
     * @param \Wpse\Http\Remote_Resource $remote
     * @return static
     */
    public static function from_slug( $slug, Remote_Resource $remote )
    {
        return new static( $slug, $remote );
    }

    /**
     * @param string                     $url Plugin URL like "https://wordpress.org/plugins/multilingual-press/"
     * @param \Wpse\Http\Remote_Resource $remote
     * @return static
     */
    public static function from_main_url( $url, Remote_Resource $remote )
    {
        $matches = [];
        preg_match( '~/plugins/([^/]*)/~', $url, $matches );

        return new static( $matches[ 1 ], $remote );
    }

    /**
     * @param string                     $url SVN URL like "https://plugins.svn.wordpress.org/multilingual-press/"
     * @param \Wpse\Http\Remote_Resource $remote
     * @return static
     */
    public static function from_svn_url( $url, Remote_Resource $remote )
    {
        $matches = [];
        preg_match( '~svn\.wordpress\.org/([^/]*)/~', $url, $matches );

        return new static( $matches[ 1 ], $remote );
    }

    /**
     * @return string
     */
    public function banner()
    {
        return $this->find( $this->banners );
    }

    /**
     * @return string
     */
    public function icon()
    {
        return $this->find( $this->icons );
    }

    /**
     * @param array $list
     * @return string
     */
    private function find( array $list )
    {
        foreach ( $list as $file )
            if ( $this->remote->exists( "$this->url/$file" ) )
                return "$this->url/$file";

        return '';
    }
}

And then we can use these classes in a few lines of code:

$assets = Wp_Org_Assets::from_main_url( 'https://wordpress.org/plugins/multilingual-press/', new Curl_Remote_Resource );
$files  = [
    'banner' => $assets->banner(),
    'icon'   => $assets->icon()
];

foreach ( $files as $name => $url )
{
    if ( $url )
        printf(
            '%1$s: <a href="https://wordpress.stackexchange.com/questions/187548/%2$s"><code>%2$s</code></a><br><img style="max-width: 100%%" src="https://wordpress.stackexchange.com/questions/187548/%2$s"><br>',
            $name,
            $url
        );
    else
        printf(
            'No %s found.<br>',
            $name
        );
}