You are here

function theme_countryicons_icon in Country Icons 6

Same name and namespace in other branches
  1. 6.2 countryicons.theme.inc \theme_countryicons_icon()
  2. 7.2 countryicons.theme.inc \theme_countryicons_icon()
  3. 7 countryicons.module \theme_countryicons_icon()

Theme a country icon.

Parameters

$code: A two letter ISO3166 country code.

$iconset: The icon set to use ('shiny' is the default).

$alt: The alternative text for text-based browsers (the two letter ISO3166 country code is the default).

$title: The title text is displayed when the image is hovered in some popular browsers.

$attributes: Associative array of attributes to be placed in the img tag.

Return value

A string containing the image tag.

File

./countryicons.module, line 132
A collection of country icons, and an API for retrieving them.

Code

function theme_countryicons_icon($code, $iconset = 'shiny', $alt = '', $title = '', $attributes = NULL) {
  $iconset = !isset($iconset) ? 'shiny' : $iconset;
  $iconsetinfo = countryicons_get_iconset($iconset);
  $path = str_replace('*', drupal_strtolower($code), $iconsetinfo['path']);
  $path = file_exists($path) ? $path : str_replace('*', 'unknown', $iconsetinfo['path']);
  $alt = $alt ? $alt : $code;
  $attributes = $attributes ? $attributes : array();
  $attributes['class'] = 'countryicon countryicon-iconset-' . drupal_strtolower($iconset) . ' countryicon-code-' . drupal_strtolower($code) . ' ' . $attributes['class'];
  return theme('image', $path, $alt, $title, $attributes);
}