You are here

function theme_ad_image_image in Advertisement 7

Same name and namespace in other branches
  1. 6.3 image/ad_image.module \theme_ad_image_image()
  2. 6 image/ad_image.module \theme_ad_image_image()
  3. 6.2 image/ad_image.module \theme_ad_image_image()

Return a themed ad image.

Parameters

$path: Either the path of the ad image file (relative to base_path()) or a full URL.

$alt: The alternative text for text-based browsers.

$tooltip: The tooltip 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.

Return value

A string containing the image tag.

1 theme call to theme_ad_image_image()
theme_ad_image_ad in image/ad_image.module
Return a themed ad of type ad_image.

File

image/ad_image.module, line 62
Enhances the ad module to support banner ads.

Code

function theme_ad_image_image(&$variables) {
  if ($variables['getsize']) {
    list($width, $height, $type, $image_attributes) = @getimagesize($variables['path']);
    if (isset($width) && isset($height)) {
      $attributes = is_array($variables['attributes']) ? $variables['attributes'] : array();
      $attributes = drupal_attributes($attributes);
      if (is_file($variables['path'])) {
        $url = preg_replace('&' . drupal_get_path('module', 'ad') . '/&', '', file_create_url($variables['path']));
      }
      else {
        $url = $variables['path'];
      }
      return '<img src="' . check_url($url) . '" alt="' . check_plain($variables['alt']) . '" title="' . check_plain($variables['tooltip']) . '" ' . $image_attributes . $attributes . ' />';
    }
  }
}