function template_preprocess_asset__gallery__widget_search in Asset 7
Preprocess variables for asset--gallery--widget-search.tpl.php.
See also
asset--gallery--widget-search.tpl.php
File
- modules/
asset_widget/ theme/ theme.inc, line 260 - Module related preprocesses and theme overrides.
Code
function template_preprocess_asset__gallery__widget_search(&$vars) {
// Render first element.
$image_assets = field_get_items('asset', $vars['asset'], 'field_asset_gallery_images');
if (!empty($image_assets[0]['target_id']) && ($asset = asset_load($image_assets[0]['target_id']))) {
$image = field_get_items('asset', $asset, 'field_asset_image');
if (!empty($image[0]['uri'])) {
$vars['media_field'] = field_view_value('asset', $asset, 'field_asset_image', $image[0], array(
'type' => 'image',
'settings' => array(
'image_style' => 'asset_image_widget_search',
'image_link' => '',
),
));
}
}
$description = field_get_items('asset', $vars['asset'], 'field_asset_gallery_desc');
if (!empty($description[0]['value'])) {
$vars['short_description'] = field_view_value('asset', $vars['asset'], 'field_asset_gallery_desc', $description[0], array(
'type' => 'text_trimmed',
'settings' => array(
'trim_length' => '140',
),
));
}
}