You are here

function scald_gallery_preprocess_scald_gallery in Scald: Gallery 7

Preprocess function for scald_gallery.tpl.php.

File

./scald_gallery.module, line 206
Scald Gallery is a Scald Atom Provider for image galleries.

Code

function scald_gallery_preprocess_scald_gallery(&$vars) {

  // Prepare items.
  $items = array();
  foreach ($vars['images'] as $image) {
    $thumb = theme('image', array(
      'path' => $image['thumb'],
      'attributes' => array(
        'data-title' => $image['title'],
        'data-big' => $image['big'],
      ),
    ));
    $items[] = l($thumb, $image['normal'], array(
      'html' => TRUE,
    ));
  }
  $vars['items'] = $items;

  // Init galleria.
  $vars['galleria_id'] = 'scald-gallery-' . $vars['atom']->sid;
  $galleria_path = libraries_get_path('galleria');
  $galleria_js_path = scald_gallery_get_library_file();
  drupal_add_js($galleria_js_path);
  $theme_js_path = scald_gallery_get_library_file($vars['galleria_options']['theme']);
  drupal_add_js($theme_js_path);
  $inline_js = "Galleria.run('#" . $vars['galleria_id'] . "');";
  drupal_add_js($inline_js, array(
    'type' => 'inline',
    'scope' => 'footer',
  ));
}