You are here

function asset_gallery_preprocess_entity in Asset 7

Process variables for entity.tpl.php.

File

modules/asset_gallery/asset_gallery.module, line 79
Code for the Image gallery asset.

Code

function asset_gallery_preprocess_entity(&$variables) {
  if ($variables['entity_type'] == 'asset') {
    $asset = $variables['asset'];
    if ($asset->type == 'image' && $variables['view_mode'] == 'gallery') {
      $content = $variables['content'];
      $item = $content['field_asset_image'][0];
      $caption = '';
      if (!empty($variables['field_asset_image_description'][0]['value'])) {
        $caption .= check_plain($variables['field_asset_image_description'][0]['value']);
      }
      if (!empty($variables['field_asset_image_copyright'][0]['value'])) {
        $caption .= '  © ' . check_plain($variables['field_asset_image_copyright'][0]['value']);
      }
      $variables['img_path'] = image_style_url($item['#image_style'], $item['#item']['uri']);
      $variables['caption'] = $caption;
    }
  }
}