You are here

function ad_image_handler_field_image in Advertisement 5.2

Same name and namespace in other branches
  1. 5 image/ad_image_views.inc \ad_image_handler_field_image()
1 string reference to 'ad_image_handler_field_image'
ad_image_views_tables in image/ad_image_views.inc

File

image/ad_image_views.inc, line 45

Code

function ad_image_handler_field_image($fieldinfo, $fielddata, $value, $data) {
  if ($fielddata['options'] == 'linkimage') {
    $ad = db_fetch_object(db_query("SELECT a.redirect, f.filepath FROM {ads} a JOIN {ad_image} i JOIN {files} f ON a.aid = i.aid AND i.aid = f.nid AND i.fid = f.fid WHERE i.aid = %d AND a.adtype = 'image'", $value));
    if ($ad) {
      ad_statistics_increment($value, 'view');
      return "<a href=\"{$ad->redirect}\"><img src=\"{$ad->filepath}\" /></a>";
    }
  }
  else {
    if ($fielddata['options'] == 'image') {
      $ad = db_fetch_object(db_query("SELECT f.filepath FROM {ad_image} i JOIN {files} f ON i.aid = f.nid AND i.fid = f.fid WHERE i.aid = %d AND a.adtype = 'image'", $value));
      if ($ad) {
        ad_statistics_increment($value, 'view');
        return "<img src=\"{$ad->filepath}\" />";
      }
    }
    else {
      $ad = db_fetch_object(db_query("SELECT f.filepath FROM {ad_image} i JOIN {files} f ON i.aid = f.nid AND i.fid = f.fid AND i.aid = %d", $value));
      return $ad->filepath;
    }
  }
}