function theme_brightcove_cck_lightbox2_player in Brightcove Video Connect 6
Same name and namespace in other branches
- 6.2 brightcove_cck/brightcove_cck.formatters.inc \theme_brightcove_cck_lightbox2_player()
Theme callback for Default thumbnail -> Lightbox2 player formatter.
Parameters
$element: Element with the Video ID.
Return value
Player HTML code.
1 string reference to 'theme_brightcove_cck_lightbox2_player'
- brightcove_cck_theme in brightcove_cck/
brightcove_cck.module - Implementation of hook_theme().
File
- brightcove_cck/
brightcove_cck.formatters.inc, line 47 - Formatters for video CCK field.
Code
function theme_brightcove_cck_lightbox2_player($element, $image = NULL, $preset = NULL) {
if (!empty($element['#item']['video_id'])) {
$field = str_replace('lightbox2_player_', '', $element['#formatter']);
$video = brightcove_video_load($element['#item']['video_id']);
/* Temporary turned off, because getting of status in BC API throws error for users without write api key
$status = brightcove_status($element['#item']['video_id']);
if ($status != BRIGHTCOVE_STATUS_COMPLETE && ($message = brightcove_expose_unavailable($status))) {
return $message;
} else if ($status != BRIGHTCOVE_STATUS_COMPLETE) {
return FALSE;
}*/
$video_name = check_plain($video->name);
if (!$image) {
if (!empty($video->{$field})) {
$image = theme('image', $video->{$field}, '', '', NULL, FALSE);
}
else {
$image = theme('image', brightcove_get_default_image(), $video_name, $video_name, array(
'width' => 120,
'height' => 120,
), FALSE);
}
}
$destination = 'brightcove_cck_player/' . $element['#node']->nid . '/' . $element['#field_name'] . '/' . $element['#item']['#delta'];
// Ugly hack to support width and height of a video - get a BC player and check it's dimensions.
$player = theme('brightcove_cck_embed', 'video', variable_get('brightcove_player', ''), variable_get('brightcove_player_key', ''), $element['#item']['video_id'], $params);
//<param name="width" value="486" />
preg_match('/<param name="width" value="(\\d{1,5})" \\/>/', $player, $width);
preg_match('/<param name="height" value="(\\d{1,5})" \\/>/', $player, $height);
$width = $width[1] + 30;
$height = $height[1] + 30;
$rel_full = 'lightframe[|width: ' . $width . 'px; height: ' . $height . 'px; overflow: visible;]';
// lightbox[' . check_plain($element['#field_name']) . ']';
$output = l($image, $destination, array(
'attributes' => array(
'rel' => $rel_full,
'class' => $element['#field_name'],
'title' => check_plain($video->name),
),
'html' => TRUE,
));
$video_width = $width - 30;
$video_height = $height - 30;
$lightbox2_width = $width;
$lightbox2_height = $height;
$video_id = $element['#item']['video_id'];
}
if ($output) {
return theme('brightcove_cck_lightbox2', $output, $video_id, $video_width, $video_height, $lightbox2_width, $lightbox2_height, $destination, $field, $element['#field_name'], $element['#type_name'], $preset);
}
}