function media_gallery_preprocess_field in Media Gallery 7.2
Same name and namespace in other branches
- 7 media_gallery.module \media_gallery_preprocess_field()
Preprocess function for theme_field().
File
- ./
media_gallery.module, line 1298
Code
function media_gallery_preprocess_field(&$variables, $hook) {
if ($variables['element']['#field_name'] === 'media_gallery_file') {
$columns = 1;
switch ($variables['element']['#view_mode']) {
case 'media_gallery_block':
$columns = $variables['element']['#object']->media_gallery_block_columns[LANGUAGE_NONE][0]['value'];
break;
case 'full':
$columns = $variables['element']['#object']->media_gallery_columns[LANGUAGE_NONE][0]['value'];
$media_gallery_view_mode_css = 'media-gallery-view-full';
break;
}
// Don't add the columning classes if the field is being displayed in a teaser
$variables['classes_array'][] = $variables['element']['#view_mode'] != 'teaser' ? 'clearfix media-gallery-media mg-col mg-col-' . $columns : 'clearfix media-gallery-media';
// add css to find draggalbe elements (see media_gallery.dragdrop.js)
if (!empty($media_gallery_view_mode_css)) {
$variables['classes_array'][] = $media_gallery_view_mode_css;
}
foreach ($variables['items'] as $delta => $item) {
$variables['item_attributes_array'][$delta] = array(
'id' => 'media-gallery-media-' . $delta,
);
}
}
}