From 0c8e7ae689eed6291bb2061c9c75e3057b230339 Mon Sep 17 00:00:00 2001 From: Mohamed Mujahid Date: Tue, 6 Jul 2010 17:04:02 +0000 Subject: merging changes from DRUPAL-6--4 --- video.theme.inc | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 video.theme.inc (limited to 'video.theme.inc') diff --git a/video.theme.inc b/video.theme.inc new file mode 100644 index 0000000..dfa36e5 --- /dev/null +++ b/video.theme.inc @@ -0,0 +1,105 @@ +'; + } + + if ($getsize) { + // Use cached width and height if available. + if (!empty($file['data']['width']) && !empty($file['data']['height'])) { + $attributes['width'] = $file['data']['width']; + $attributes['height'] = $file['data']['height']; + } + // Otherwise pull the width and height from the file. + elseif (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath'])) { + $attributes['width'] = $width; + $attributes['height'] = $height; + } + } + + if (!empty($title)) { + $attributes['title'] = $title; + } + + // Alt text should be added even if it is an empty string. + $attributes['alt'] = $alt; + + // Add a timestamp to the URL to ensure it is immediately updated after editing. + $query_string = ''; + if (isset($file['timestamp'])) { + $query_character = (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE && variable_get('clean_url', '0') == '0') ? '&' : '?'; + $query_string = $query_character . $file['timestamp']; + } + + $url = file_create_url($file['filepath']) . $query_string; + $attributes['src'] = $url; + $attributes = drupal_attributes($attributes); + return ''; +} + +function theme_video_widget_preview($item) { + return theme('filefield_widget_preview', $item); +} + +function theme_video_widget_video_thumb($item = NULL) { + return '
' . theme('video_image', $item, '', '', '', FALSE) . '
'; +} + +/** + * @defgroup "Theme Callbacks" + * @{ + * @see uploadfield_theme(). + */ +function theme_video_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE, $imagecache = FALSE) { + $file = (array)$file; + //if this is imagecache skip this as the file might not be created yet + if (!$imagecache && !is_file($file['filepath'])) { + return ''; + } + + if ($getsize && $imagecache && ($image = image_get_info($file['filepath']))) { + $attributes['width'] = $image['width']; + $attributes['height'] = $image['height']; + } + elseif ($getsize) { + // Use cached width and height if available. + if (!empty($file['data']['width']) && !empty($file['data']['height'])) { + $attributes['width'] = $file['data']['width']; + $attributes['height'] = $file['data']['height']; + } + // Otherwise pull the width and height from the file. + elseif (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath'])) { + $attributes['width'] = $width; + $attributes['height'] = $height; + } + } + + if (!empty($title)) { + $attributes['title'] = $title; + } + + // Alt text should be added even if it is an empty string. + $attributes['alt'] = $alt; + + // Add a timestamp to the URL to ensure it is immediately updated after editing. + $query_string = ''; + if (isset($file['timestamp'])) { + $query_character = (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE && variable_get('clean_url', '0') == '0') ? '&' : '?'; + $query_string = $query_character . $file['timestamp']; + } + + $url = file_create_url($file['filepath']) . $query_string; + $attributes['src'] = $url; + $attributes = drupal_attributes($attributes); + return ''; +} \ No newline at end of file -- cgit v1.2.3