function views_rss_core_preprocess_channel_image in Views RSS 7.2
Same name and namespace in other branches
- 8.3 modules/views_rss_core/views_rss_core.inc \views_rss_core_preprocess_channel_image()
- 8.2 modules/views_rss_core/views_rss_core.inc \views_rss_core_preprocess_channel_image()
- 6.2 modules/views_rss_core/views_rss_core.inc \views_rss_core_preprocess_channel_image()
Preprocess function for channel <image> element.
1 string reference to 'views_rss_core_preprocess_channel_image'
- views_rss_core_views_rss_channel_elements in modules/
views_rss_core/ views_rss_core.module - Implements hook_views_rss_channel_elements().
File
- modules/
views_rss_core/ views_rss_core.inc, line 80 - Preprocess functions for Views RSS: Core Elements module.
Code
function views_rss_core_preprocess_channel_image(&$variables) {
// No value = no preprocessing.
if (empty($variables['elements'][0]['value'])) {
return;
}
$path = $variables['elements'][0]['value'];
// Get value of channel <title> element from its preprocess function.
views_rss_core_preprocess_channel_title($variables);
$title = $variables['elements'][0]['value'];
// Get value of channel <title> element from its preprocess function.
views_rss_core_preprocess_channel_link($variables);
$link = $variables['elements'][0]['value'];
// Create subelements array.
$variables['elements'][0]['value'] = array(
'url' => file_create_url($path),
'title' => $title,
'link' => $link,
);
// Try to get image description from website's mission.
$site_slogan = variable_get('site_slogan', '');
if (!empty($site_slogan)) {
$variables['elements'][0]['value']['description'] = $site_slogan;
}
// Get image width and height.
$image = image_load($path);
if (!empty($image)) {
$variables['elements'][0]['value']['width'] = $image->info['width'];
$variables['elements'][0]['value']['height'] = $image->info['height'];
}
}