public function video_helper::thumbnail_object in Video 6.4
Same name and namespace in other branches
- 6.5 includes/video_helper.inc \video_helper::thumbnail_object()
- 7 includes/video_helper.inc \video_helper::thumbnail_object()
1 call to video_helper::thumbnail_object()
- video_helper::video_object in includes/
video_helper.inc
File
- includes/
video_helper.inc, line 88
Class
Code
public function thumbnail_object($element) {
$field = content_fields($element['#field_name'], $element['#type_name']);
// Build our thumbnail object
$thumbnail = new stdClass();
$thumbnail->filepath = '';
$thumbnail->url = '';
//@todo future enhancements for our thumbnails
$thumbnail->alt = '';
$thumbnail->title = '';
$thumbnail->description = '';
// Setup our thumbnail path.
$use_default_img = isset($element['#item']['data']['use_default_video_thumb']) ? $element['#item']['data']['use_default_video_thumb'] : false;
if ($use_default_img && !empty($field['widget']['default_video_thumb']['filepath'])) {
$thumbnail->filepath = $field['widget']['default_video_thumb']['filepath'];
}
elseif (isset($element['#item']['data']['video_thumb']) ? $element['#item']['data']['video_thumb'] : false) {
$thumbnail->filepath = $element['#item']['data']['video_thumb'];
}
else {
//need some type of default if nothing is present
//drupal_set_message(t('No thumbnail has been configured for the video.'), 'error');
}
//lets check for an imagecache preset
if (isset($element['imagecache_preset'])) {
$thumbnail->url = imagecache_create_url($element['imagecache_preset'], $thumbnail->filepath);
$thumbnail->filepath = imagecache_create_path($element['imagecache_preset'], $thumbnail->filepath);
}
else {
$thumbnail->url = file_create_url($thumbnail->filepath);
}
//swftools appends sites/default/files to the front of our path...
//@todo Is this a setting? Need to figure this out.
$thumbnail->swfthumb = $thumbnail->filepath;
// filemime
$thumbnail->filemime = file_get_mimetype($thumbnail->filepath);
// Return our object
return $thumbnail;
}