### Eclipse Workspace Patch 1.0
#P drupal-contrib
Index: modules/ad/image/ad_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ad/image/ad_image.module,v
retrieving revision 1.2.2.13.2.40
diff -u -r1.2.2.13.2.40 ad_image.module
--- modules/ad/image/ad_image.module 11 Aug 2008 18:04:27 -0000 1.2.2.13.2.40
+++ modules/ad/image/ad_image.module 22 Aug 2008 12:49:22 -0000
@@ -13,15 +13,7 @@
* Function used to display the selected ad.
*/
function ad_image_display_ad($ad) {
- // Strip module path from image path if serving images from adserve.php.
- $image_path = preg_replace('&'. drupal_get_path('module', 'ad') .'/&', '', file_create_url($ad->filepath));
- if ($ad->url) {
- $ad_image = "
";
- }
- else {
- $ad_image = "aid\">

width\" height=\"$ad->height\" alt=\"". htmlentities($ad->tooltip, ENT_QUOTES, 'UTF-8') ."\" />
";
-
- }
+ $ad_image = theme('ad_image_ad', $ad);
if (variable_get('ad_filter', 0)) {
$ad_image = check_markup($ad_image, $ad->format, FALSE);
}
@@ -450,3 +442,49 @@
}
}
+/**
+ * Return a themed ad image.
+ *
+ * @param $path
+ * Either the path of the ad image file (relative to base_path()) or a full URL.
+ * @param $alt
+ * The alternative text for text-based browsers.
+ * @param $title
+ * The title text is displayed when the image is hovered in some popular browsers.
+ * @param $attributes
+ * Associative array of attributes to be placed in the img tag.
+ * @param $getsize
+ * If set to TRUE, the image's dimension are fetched and added as width/height attributes.
+ * @return
+ * A string containing the image tag.
+ */
+function theme_ad_image_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
+ if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
+ $attributes = drupal_attributes($attributes);
+ $url = preg_replace('&'. drupal_get_path('module', 'ad') .'/&', '', file_create_url($path));
+ return '
';
+ }
+}
+
+/**
+ * Return a themed ad of type ad_image
+ *
+ * @param $ad
+ * The ad object
+ * @return
+ * A string containing the ad markup.
+ */
+function theme_ad_image_ad($ad) {
+ $output = '';
+ if ($ad->url) {
+ $link_attributes = ad_link_attributes();
+ $link_attributes['title'] = $ad->tooltip;
+ $img = theme('ad_image_image', $ad->filepath, $ad->tooltip, $ad->title);
+ $output .= l($img, $ad->url, $link_attributes, NULL, NULL, FALSE, TRUE);
+ }
+ else {
+ $output .= theme('ad_image_image', $ad->filepath, $ad->tooltip, $ad->title);
+ }
+ $output .= '
';
+ return $output;
+}
\ No newline at end of file