aboutsummaryrefslogtreecommitdiff
path: root/includes/video_views_handler_field_image.inc
diff options
context:
space:
mode:
authorglen201 <glen201@527446.no-reply.drupal.org>2009-07-31 02:01:53 +0000
committerglen201 <glen201@527446.no-reply.drupal.org>2009-07-31 02:01:53 +0000
commitb66f50d2ce11d0cc8bb53af94ad86278d3fe8e51 (patch)
tree0a9b459d44a0d2729c479d5393e87cd94cb785f2 /includes/video_views_handler_field_image.inc
parent2524eecbeef2c8b3c0d80a5ffcde2604da50e30c (diff)
downloadvideo-b66f50d2ce11d0cc8bb53af94ad86278d3fe8e51.tar.gz
video-b66f50d2ce11d0cc8bb53af94ad86278d3fe8e51.tar.bz2
#486064: by RobertOak "no video fields in views" Fixed, added Views 2 support
.MPEG/MPG defaulted to play with Windows Media
Diffstat (limited to 'includes/video_views_handler_field_image.inc')
-rw-r--r--includes/video_views_handler_field_image.inc74
1 files changed, 74 insertions, 0 deletions
diff --git a/includes/video_views_handler_field_image.inc b/includes/video_views_handler_field_image.inc
new file mode 100644
index 0000000..fbbe905
--- /dev/null
+++ b/includes/video_views_handler_field_image.inc
@@ -0,0 +1,74 @@
+<?php
+//$Id$
+/**
+* Implementation of hook_views_tables
+*
+* @return
+* array - Enables support in the video module for views integration
+ * @author Glen Marianko Twitter@demoforum <glenm at demoforum dot com>
+ * @todo
+**/
+
+/**
+ * Field handler to display the video preview thumbnail
+ *
+ * @ingroup views_field_handlers
+ */
+class video_views_handler_field_image extends views_handler_field {
+ /**
+ * Define options available for this field.
+ */
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['img_type'] = array('default' => 'thumbnail');
+ $options['disp_link'] = array('default' => TRUE);
+ return $options;
+ }
+
+ /**
+ * Build option configuration form.
+ */
+ 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'],
+ );
+
+ }
+/**
+ * Render field output to the browser.
+ */
+ function render($values) {
+ return _video_views_handler_field_image($values, $this->options['img_type'], $this->options['disp_link']);
+ }
+}
+/**
+* Handler to render the preview image associated with a video
+**/
+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'));
+ //Create a link with an image in it.
+ $output .= ($linked ? l($image_html, "node/$values->nid", array('html' => TRUE)) : $image_html);
+ $output .= '<br class="video_image_clear" />';
+ }
+ }
+ return $output;
+}