-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews_photo_grid.module
41 lines (33 loc) · 1.01 KB
/
views_photo_grid.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* @file
* Module file for the Views Photo Grid module.
*/
/**
* Implements hook_views_api().
*/
function views_photo_grid_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'views_photo_grid') .'/views',
);
}
/**
* Preprocesses variables for the photo grid template.
*/
function template_preprocess_views_photo_grid_style(&$vars) {
$view = $vars['view'];
$handler = $view->style_plugin;
$rendered_fields = $handler->render_fields($view->result);
$image_field = $handler->get_image_field_name();
$vars['items'] = array();
foreach ($rendered_fields as $key => $row) {
if (!empty($row[$image_field])) {
$vars['items'][] = $row[$image_field];
}
}
$module_dir = drupal_get_path('module', 'views_photo_grid');
drupal_add_css($module_dir . '/css/views-photo-grid.css');
drupal_add_js(array('viewsPhotoGrid' => array('gridPadding' => $handler->options['grid_padding'])), 'setting');
drupal_add_js($module_dir . '/js/views-photo-grid.js');
}