I have attached a patch that adds new functionality to the Emvideo module. The patch creates a new display format Lightbox2: Node Title -> Full Size Video. This allows videos to be displayed as links that are then displayed and played within a Lightbox 2 popup when clicked. The new display format is available under the Display Fields section of content types containing a video related CCK field. It is also available under the Format section of video related fields in Views.

I have applied the patch to the latest dev version of Embedded Media Field and tested it locally - everything works as it should do. We also applied the patch to the most recent stable version of Emfield on a production site, and it works fine there also.

Please review the patch and consider adding this functionality to the Emvideo module, as I am sure it will prove useful to others.

Thanks.

CommentFileSizeAuthor
#1 emvideo_lightbox2_link.patch5.94 KBstephenh
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stephenh’s picture

Would help if I included the patch - here you go.

tizzo’s picture

Status: Needs review » Needs work

This looks like a fairly clean patch. For coding standards, however, we need to fix the following:

    'emvideo_formatter_lightbox2_link' => array(
    'arguments' => array('element' => NULL),
    'file' => 'emvideo.theme.inc'
   ),

Should read:

    'emvideo_formatter_lightbox2_link' => array(
      'arguments' => array('element' => NULL),
      'file' => 'emvideo.theme.inc'
    ),
yngvewb’s picture

I would love to have this this functionality in 2.0, could we also make a "Lightbox2: _Link_ -> Full Size Video"?

Junro’s picture

Hello,

Patch #1 doesn't seem to work for me. I don't have the new format in view.

@tizzo ??

Needs work? These spaces don't change anything I think...

Embedded Media Field really needs to have this feature :)

korzh-nick’s picture

Thanks for the job! But the codes are not valid for xhtml1 strict

  <div class="views-field-field-youtube-embed">
                <span class="field-content"><div class="emvideo-modal emvideo-lightbox2"><a href="/emvideo/modal/949/800/450/field_youtube/youtube/-giJE8YTYdg" title="" class="emvideo-thumbnail-replacement emvideo-modal-lightbox2 lightbox2" rel="lightframe[feed_item|width:816; height:466;]"><img src="/sites/default/files/youtube/emvideo-youtube--giJE8YTYdg_3.jpg" alt="" title=""  width="200" height="150" /></a></div></span></div>
document type does not allow element "div" here; missing one of "object", "ins", "del", "map", "button" start-tag

…lass="emvideo-modal emvideo-lightbox2"><a href="/emvideo/modal/949/800/450/fie…

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

Please advise if anything

Yuri’s picture

I also need this Lightbox2: Node Title -> Full Size Video but it is not available in the current stable EMfield module version 6.x-2.5
Is this idea abandoned?

bradallenfisher’s picture

To validate you need to take the div out of the span. It is pretty easy.
Just add the theme function to your template.php.
My theme is called aa so i put this at the end of my template.php file.
The only thing I changed was I replaced the divs with spans

function aa_emvideo_modal_generic($field, $item, $formatter, $node, $options = array()) {
  $title = isset($options['title']) ? $options['title'] : (isset($item['title']) ? $item['title'] : (isset($node->title) ? $node->title : (isset($node->node_title) ? $node->node_title : (isset($field['widget']['thumbnail_link_title']) ? $field['widget']['thumbnail_link_title'] : variable_get('emvideo_default_thumbnail_link_title', t('See video'))))));
  $thumbnail = isset($options['thumbnail']) ? $options['thumbnail'] : theme('emvideo_video_thumbnail', $field, $item, 'video_thumbnail', $node, TRUE, $options);
  $width = ($formatter == 'video_replace_preview') ? $field['widget']['preview_width'] : $field['widget']['video_width'];
  $height = ($formatter == 'video_replace_preview') ? $field['widget']['preview_height'] : $field['widget']['video_height'];
  $destination = 'emvideo/modal/'. $node->nid .'/'. $width .'/'. $height .'/'. $field['field_name'] .'/'. $item['provider'] .'/'. $item['value'];
  $link_class = 'emvideo-thumbnail-replacement emvideo-modal-' . $options['modal'] .' '. $options['modal'];
  $attributes = array(
    'attributes' => array(
      'title' => $title,
      'class' => $link_class,
    ),
    'query' => NULL,
    'fragment' => NULL,
    'absolute' => FALSE,
    'html' => TRUE,
  );
  if ($options['modal'] == 'lightbox2') {
    $attributes['attributes']['rel'] = 'lightframe['. $field['type_name'] .'|width:'. ($width + 16) .'; height:'. ($height + 16) .';]';
  }
  else if ($options['modal'] == 'shadowbox') {
    $attributes['attributes']['rel'] = 'shadowbox['. $field['type_name'] .'];width='. ($width + 5) .';height='. ($height + 5);
    // Shadowbox needs a .php extension so it knows to open as an iFrame.
    $destination .= '/index.php';
  }
  else if ($options['modal'] == 'colorbox-load') {
    $attributes['query'] = 'width='. ($width + 4) .'&height='. ($height + 7) .'&iframe=true';
  }

  if (($options['modal'] == 'lightbox2') && function_exists('lightbox2_add_files')) {
    lightbox2_add_files();
  }

  static $added_js;
  if (!isset($added_js)) {
    // Add the play button image overlay.
    drupal_add_js(array('emvideo' => array('thumbnail_overlay' => variable_get('emfield_thumbnail_overlay', TRUE))), 'setting');
    drupal_add_js(drupal_get_path('module', 'emvideo') . '/emvideo.thumbnail-replacement.js');
    drupal_add_css(drupal_get_path('module', 'emvideo') . '/emvideo.thumbnail-replacement.css');
    $added_js = TRUE;
  }
  $class = 'emvideo-modal emvideo-'. $options['modal'];
  if ($options['wrapper-class']) {
    $class .= ' '. $options['wrapper-class'];
  }
  $display_title = '';
  // Create "title" container
  if (isset($options['title'])) {
    $display_title = '<span class="item-title">'. $options['title'] ."</span>";
  } else if (isset($item['title'])) {
    $display_title = '<span class="item-title">'. $item['title']. "</span>";
  }
  $output = '<span class="'. $class .'">'. l($thumbnail, $destination, $attributes) . $display_title .'</span>';
  return $output;
}