video_views_handler_field_image.inc in Video 6.2
File
views/video_views_handler_field_image.inc
View source
<?php
class video_views_handler_field_image extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['img_type'] = array(
'default' => 'thumbnail',
);
$options['disp_link'] = array(
'default' => TRUE,
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['img_type'] = array(
'#title' => t('Show image as'),
'#type' => 'select',
'#options' => array(
'thumbnail' => t('Thumbnail'),
'preview' => t('Preview'),
),
'#default_value' => $this->options['img_type'],
);
$form['disp_link'] = array(
'#title' => t('Link image to video'),
'#type' => 'checkbox',
'#default_value' => $this->options['disp_link'],
);
}
function render($values) {
return _video_views_handler_field_image($values, $this->options['img_type'], $this->options['disp_link']);
}
}
function _video_views_handler_field_image($values, $image_type, $linked) {
if ($values->node_type && $values->node_type != 'video') {
return NULL;
}
$node = node_load($values->nid);
$output = NULL;
if ($node->iid && ($image = node_load($node->iid))) {
$image_html = NULL;
if ($image != NULL && $image->type == 'image') {
$image_html = image_display($image, $image_type, array(
'class' => 'video_image_teaser',
));
$output .= $linked ? l($image_html, "node/{$values->nid}", array(
'html' => TRUE,
)) : $image_html;
$output .= '<br class="video_image_clear" />';
}
}
return $output;
}