From e06647587abf3e384a6461c93031f07d35b74098 Mon Sep 17 00:00:00 2001 From: Heshan Wanigasooriya Date: Sun, 9 Jan 2011 07:55:29 +0000 Subject: Updating module for drupal7 file system API --- video.theme.inc | 67 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 16 deletions(-) (limited to 'video.theme.inc') diff --git a/video.theme.inc b/video.theme.inc index 4910460..521022a 100644 --- a/video.theme.inc +++ b/video.theme.inc @@ -1,4 +1,5 @@ '; + return ''; } if ($getsize) { // Use cached width and height if available. if (!empty($file['data']['width']) && !empty($file['data']['height'])) { - $attributes['width'] = $file['data']['width']; + $attributes['width'] = $file['data']['width']; $attributes['height'] = $file['data']['height']; } // Otherwise pull the width and height from the file. @@ -44,11 +44,14 @@ function theme_video_thumbnails($file, $alt = '', $title = '', $attributes = NUL $url = file_create_url($file['filepath']) . $query_string; $attributes['src'] = $url; $attributes = drupal_attributes($attributes); - return ''; + return ''; } function theme_video_widget_preview($item) { - return theme('filefield_widget_preview', $item); + $output .= '
'; + $output .= drupal_render($item['preview']); + $output .= '
'; + return $item; } function theme_video_widget_video_thumb($item = NULL) { @@ -61,20 +64,19 @@ function theme_video_widget_video_thumb($item = NULL) { * @see uploadfield_theme(). */ function theme_video_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE, $imagecache = FALSE) { - $file = (array)$file; + $file = (array) $file; //if this is imagecache skip this as the file might not be created yet if (!$imagecache && !is_file($file['filepath'])) { - return ''; + 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. + } elseif ($getsize) { + // Use cached width and height if available. if (!empty($file['data']['width']) && !empty($file['data']['height'])) { - $attributes['width'] = $file['data']['width']; + $attributes['width'] = $file['data']['width']; $attributes['height'] = $file['data']['height']; } // Otherwise pull the width and height from the file. @@ -101,7 +103,7 @@ function theme_video_image($file, $alt = '', $title = '', $attributes = NULL, $g $url = file_create_url($file['filepath']) . $query_string; $attributes['src'] = $url; $attributes = drupal_attributes($attributes); - return ''; + return ''; } /** @@ -116,15 +118,15 @@ function theme_video_image($file, $alt = '', $title = '', $attributes = NULL, $g function theme_video_widget($variables) { $element = $variables['element']; $output = ''; - $output .= '
'; + $output .= '
'; if (isset($element['preview'])) { - $output .= '
'; + $output .= '
'; $output .= drupal_render($element['preview']); $output .= '
'; } - $output .= '
'; + $output .= '
'; if ($element['fid']['#value'] != 0) { $element['filename']['#markup'] .= ' (' . format_size($element['#file']->filesize) . ') '; } @@ -134,3 +136,36 @@ function theme_video_widget($variables) { return $output; } + +/** + * Returns HTML for an image using a specific image style. + * + * @param $variables + * An associative array containing: + * - style_name: The name of the style to be used to alter the original image. + * - path: The path of the image file relative to the Drupal files directory. + * This function does not work with images outside the files directory nor + * with remotely hosted images. + * - alt: The alternative text for text-based browsers. + * - title: The title text is displayed when the image is hovered in some + * popular browsers. + * - attributes: Associative array of attributes to be placed in the img tag. + * - getsize: If set to TRUE, the image's dimension are fetched and added as + * width/height attributes. + * + * @ingroup themeable + */ +function theme_video_thumb_style($variables) { + $style_name = $variables['style_name']; + $path = $variables['path']; + + // theme_image() can only honor the $getsize parameter with local file paths. + // The derivative image is not created until it has been requested so the file + // may not yet exist, in this case we just fallback to the URL. + $style_path = image_style_path($style_name, $path); + if (!file_exists($style_path)) { + $style_path = image_style_url($style_name, $path); + } + $variables['path'] = $style_path; + return theme('image', $variables); +} \ No newline at end of file -- cgit v1.2.3