diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-09-22 03:24:09 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-09-22 03:24:09 +0000 |
commit | 63b9e4770b7bf205a9b707264cb6f77354f77ecd (patch) | |
tree | 71c5398c02d35c8b2d365254acdf55764817eee4 /includes/theme.inc | |
parent | cdf28e6fd6aa87b8e0302bcc88505f378a38968d (diff) | |
download | brdo-63b9e4770b7bf205a9b707264cb6f77354f77ecd.tar.gz brdo-63b9e4770b7bf205a9b707264cb6f77354f77ecd.tar.bz2 |
- Patch #908282 by jbrown: theme_image() performs I/O.
Diffstat (limited to 'includes/theme.inc')
-rw-r--r-- | includes/theme.inc | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index 87c8dba50..832f8719d 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1479,6 +1479,8 @@ function theme_links($variables) { * An associative array containing: * - path: Either the path of the image file (relative to base_path()) or a * full URL. + * - width: The width of the image (if known). + * - height: The height of the image (if known). * - alt: The alternative text for text-based browsers. HTML 4 and XHTML 1.0 * always require an alt attribute. The HTML 5 draft allows the alt * attribute to be omitted in some cases. Therefore, this variable defaults @@ -1492,38 +1494,19 @@ function theme_links($variables) { * - 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. */ function theme_image($variables) { - $path = $variables['path']; - $alt = $variables['alt']; - $title = $variables['title']; $attributes = $variables['attributes']; - $getsize = $variables['getsize']; + $attributes['src'] = file_create_url($variables['path']); - if (!$getsize || (is_file($path) && (list($width, $height) = @getimagesize($path)))) { - // The src attribute can be omitted, by passing NULL for $path and FALSE for - // $getsize. - if (isset($path)) { - $attributes['src'] = file_create_url($path); - } - // The alt attribute defaults to an empty string. By passing NULL as value, - // it can be omitted. - if (isset($alt)) { - $attributes['alt'] = $alt; - } - if (isset($title)) { - $attributes['title'] = $title; - } - if (!isset($attributes['width']) && !empty($width)) { - $attributes['width'] = $width; - } - if (!isset($attributes['height']) && !empty($height)) { - $attributes['height'] = $height; + foreach (array('width', 'height', 'alt', 'title') as $key) { + + if (isset($variables[$key])) { + $attributes[$key] = $variables[$key]; } - return '<img' . drupal_attributes($attributes) . ' />'; } + + return '<img' . drupal_attributes($attributes) . ' />'; } /** |