xtomdex/country-flags

Class for getting country flag image URL

1.0.0 2019-11-03 18:43 UTC

This package is auto-updated.

Last update: 2024-04-06 05:07:47 UTC


README

Class for getting country flag image URL. Details on Country Flag API website.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist xtomdex/country-flags "*"

or add

"xtomdex/country-flags": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

<?php
 
 $imageUrl = \xtomdex\countryflags\CountryFlag::get('be');
 
 ?>

<img src="<?=$imageUrl?>" alt="Belgium flag image">

You can get images of different sizes (16, 24, 32, 48 and 64 pixels) by passing the size in the second param (by default image is 16px).

 
 $imageUrl = \xtomdex\countryflags\CountryFlag::get('be', 64);
 

Also it is possible to change flag image style. Only two options are available and by default it is shiny. You can switch it to flat by passing flat style constant in the third argument.

use \xtomdex\countryflags\CountryFlag;

 $imageUrl = CountryFlag::get('be', 32, CountryFlag::STYLE_FLAT);