diff options
author | Heshan Wanigasooriya <heshanmw@gmail.com> | 2011-01-09 07:55:29 +0000 |
---|---|---|
committer | Heshan Wanigasooriya <heshanmw@gmail.com> | 2011-01-09 07:55:29 +0000 |
commit | e06647587abf3e384a6461c93031f07d35b74098 (patch) | |
tree | da6154a0839a522028536a85cb1f5a37447e8f44 /video.theme.inc | |
parent | 65e4e46dbbdd0b2e25977e0365ac215f8f6f399e (diff) | |
download | video-e06647587abf3e384a6461c93031f07d35b74098.tar.gz video-e06647587abf3e384a6461c93031f07d35b74098.tar.bz2 |
Updating module for drupal7 file system API
Diffstat (limited to 'video.theme.inc')
-rw-r--r-- | video.theme.inc | 67 |
1 files changed, 51 insertions, 16 deletions
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 @@ <?php + //$Id$ /** * @@ -6,18 +7,17 @@ * Theme functions for the video module. * */ - function theme_video_thumbnails($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) { - $file = (array)$file; + $file = (array) $file; // return $file['filepath']; if (!is_file($file['filepath'])) { - return '<!-- File not found: '. $file['filepath'] .' -->'; + return '<!-- File not found: ' . $file['filepath'] . ' -->'; } 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 '<span></span><img '. $attributes .' />'; + return '<span></span><img ' . $attributes . ' />'; } function theme_video_widget_preview($item) { - return theme('filefield_widget_preview', $item); + $output .= '<div class="image-preview">'; + $output .= drupal_render($item['preview']); + $output .= '</div>'; + 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 '<!-- File not found: '. str_replace("--", "-", $file['filepath']) .'" -->'; + return '<!-- File not found: ' . str_replace("--", "-", $file['filepath']) . '" -->'; } 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 '<img '. $attributes .' />'; + return '<img ' . $attributes . ' />'; } /** @@ -116,15 +118,15 @@ function theme_video_image($file, $alt = '', $title = '', $attributes = NULL, $g function theme_video_widget($variables) { $element = $variables['element']; $output = ''; - $output .= '<div class="image-widget form-managed-file clearfix">'; + $output .= '<div class="video-widget form-managed-file clearfix">'; if (isset($element['preview'])) { - $output .= '<div class="image-preview">'; + $output .= '<div class="video-preview">'; $output .= drupal_render($element['preview']); $output .= '</div>'; } - $output .= '<div class="image-widget-data">'; + $output .= '<div class="video-widget-data">'; if ($element['fid']['#value'] != 0) { $element['filename']['#markup'] .= ' <span class="file-size">(' . format_size($element['#file']->filesize) . ')</span> '; } @@ -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 |