function scald_gallery_scald_prerender in Scald: Gallery 7
Same name and namespace in other branches
- 7.2 scald_gallery.module \scald_gallery_scald_prerender()
Implements hook_scald_prerender().
File
- ./
scald_gallery.module, line 162 - Scald Gallery is a Scald Atom Provider for image galleries.
Code
function scald_gallery_scald_prerender($atom, $context, $options, $mode) {
if ($mode == 'player') {
// Galleria display settings.
$config = scald_context_config_load($context);
$normal_style = $config->player[$atom->type]['settings']['normal_style'];
$thumb_style = $config->player[$atom->type]['settings']['thumb_style'];
$big_style = $config->player[$atom->type]['settings']['big_style'];
$galleria_opts = array(
'width' => $config->player[$atom->type]['settings']['width'],
'height' => $config->player[$atom->type]['settings']['height'],
'theme' => $config->player[$atom->type]['settings']['theme'],
);
// Load URLs to thumb, normal and fullscreen images.
$images = array();
$items = field_get_items('scald_atom', $atom, 'gallery_items');
foreach ($items as $item) {
$item_atom = scald_atom_load($item['sid']);
if ($atom) {
$thumbnail = field_get_items('scald_atom', $item_atom, 'scald_thumbnail');
if (!empty($thumbnail[0]['fid'])) {
$file = file_load($thumbnail[0]['fid']);
if ($file) {
$images[] = array(
'thumb' => $thumb_style == 'original' ? file_create_url($file->uri) : image_style_url($thumb_style, $file->uri),
'normal' => $normal_style == 'original' ? file_create_url($file->uri) : image_style_url($normal_style, $file->uri),
'big' => $big_style == 'original' ? file_create_url($file->uri) : image_style_url($big_style, $file->uri),
'title' => check_plain($item_atom->title),
);
}
}
}
}
$atom->rendered->player = theme('scald_gallery', array(
'atom' => $atom,
'images' => $images,
'galleria_options' => $galleria_opts,
));
// We are not caching since we include JS in preprocess.
$atom->rendered->nocache = TRUE;
}
}