You are here

function ad_image_load_image in Advertisement 7

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

Returns image object from given ad node.

File

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

Code

function ad_image_load_image($node) {
  if (isset($node->remote_image) && !empty($node->remote_image)) {
    $file->filename = $node->remote_image;
    $file->filepath = $node->remote_image;
    $image = ad_image_validate_size($file, $node->nid);
    if ($image !== FALSE) {
      return $image;
    }
  }
  else {
    if (isset($node->files) && is_array($node->files)) {
      foreach ($node->files as $file) {
        if (is_array($file)) {
          if ($file['list'] && file_exists($file['filepath'])) {
            $image = ad_image_validate_size((object) $file, $node->nid);
            if ($image !== FALSE) {
              $image->fid = $file['fid'];
              return $image;
            }
          }
        }
        else {
          if ($file->list && file_exists($file->filepath)) {
            $image = ad_image_validate_size($file, $node->nid);
            if ($image !== FALSE) {
              $image->fid = $file->fid;
              return $image;
            }
          }
        }
      }
    }
  }
  return FALSE;
}