function _weather_get_image in Weather 5.6
Same name and namespace in other branches
- 5 weather.module \_weather_get_image()
- 6.5 weather.module \_weather_get_image()
1 call to _weather_get_image()
- theme_weather in ./
weather.module - Custom theme function for the weather block output
File
- ./
weather.module, line 411 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function _weather_get_image($metar) {
// is there any data available?
if (!isset($metar['condition_text'])) {
$name = 'nodata';
}
else {
// handle special case: NSC, we just use few for the display
if ($metar['condition_text'] == 'no-significant-clouds') {
$metar['condition_text'] = 'few';
}
// calculate the sunrise and sunset times for day/night images
$name = $metar['daytime']['condition'] . '-' . $metar['condition_text'];
// handle rain images
if (isset($metar['phenomena']['rain'])) {
$rain = $metar['phenomena']['rain'];
}
else {
if (isset($metar['phenomena']['drizzle'])) {
$rain = $metar['phenomena']['drizzle'];
}
else {
if (isset($metar['phenomena']['snow'])) {
$snow = $metar['phenomena']['snow'];
}
}
}
if (isset($rain)) {
if (isset($rain['#light'])) {
$name .= '-light-rain';
}
else {
if (isset($rain['#heavy'])) {
$name .= '-heavy-rain';
}
else {
$name .= '-moderate-rain';
}
}
}
if (isset($snow)) {
if (isset($snow['#light'])) {
$name .= '-light-snow';
}
else {
if (isset($snow['#heavy'])) {
$name .= '-heavy-snow';
}
else {
$name .= '-moderate-snow';
}
}
}
}
// set up final return array
$image['filename'] = base_path() . drupal_get_path('module', 'weather') . '/images/' . $name . '.png';
$size = getimagesize(drupal_get_path('module', 'weather') . '/images/' . $name . '.png');
$image['size'] = $size[3];
return $image;
}