image_gallery_handler_field_gallery_cover_thumbnail.inc in Image 6
File
contrib/image_gallery/views/image_gallery_handler_field_gallery_cover_thumbnail.inc
View source
<?php
class image_gallery_handler_field_gallery_cover_thumbnail extends image_gallery_handler_field_gallery_cover {
function option_definition() {
$options = parent::option_definition();
$options['image_derivative'] = array(
'default' => array(
IMAGE_THUMBNAIL,
),
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['descendants']['#description'] = theme('advanced_help_topic', 'image_gallery', 'descendants') . t('Whether to go into subgalleries when getting a cover image. Either: consider only this gallery itself, consider subgalleries all together, or recurse into subgalleries one by one if the gallery itself is empty.');
$form['descendants']['#options'] = array(
'single' => t('Only get cover image from this gallery'),
'flat' => t('Consider subgalleries, flattened.'),
'recurse' => t('Consider subgalleries, recursively. (Warning: this can produce many queries per row if your parent galleries are empty!).'),
);
foreach (image_get_sizes() as $key => $size) {
$sizes[$key] = $size['label'];
}
$form['image_derivative'] = array(
'#type' => 'select',
'#title' => t('Image size to show'),
'#options' => $sizes,
'#default_value' => $this->options['image_derivative'],
'#description' => t('Pick an image derivative to display.'),
);
}
function render($values) {
$nid = $this
->get_cover_node_nid($values);
$latest_node = node_load($nid);
$output = image_display($latest_node, $this->options['image_derivative']);
$output = $this
->render_link($output, $values);
return '<span class="image-gallery-view-cover-thumbnail">' . $output . '</span>';
}
}