You are here

function uc_option_image_load in Ubercart Option Images 6

Load image file.

@todo: static cache

4 calls to uc_option_image_load()
uc_option_image in ./uc_option_image.module
Add JavaSript and CSS in order to run uc_option_image's switching functionality.
uc_option_image_form_alter in ./uc_option_image.module
Implements hook_form_alter().
uc_option_image_form_uc_cart_view_form_alter in ./uc_option_image.module
Implements hook_form_FORM_ID_alter() for the "uc_object_options" form.
uc_option_image_nodeapi in ./uc_option_image.module
Implements hook_nodeapi().

File

./uc_option_image.module, line 398
Provides image upload fields for attribute options. @author Tj Holowaychuk <tj@vision-media.ca/> @link http://vision-media.ca @todo supply 'default' image field when no option images are supplied or no option image attributes are…

Code

function uc_option_image_load($nid, $aid, $oid) {
  static $files;
  $filename = uc_option_image_id($nid, $aid, $oid);
  if (empty($files[$filename])) {
    $files[$filename] = db_fetch_object(db_query("SELECT * FROM {files} WHERE filename = '%s'", $filename));
    if (empty($files[$filename])) {
      if ($nid) {
        return uc_option_image_load(0, $aid, $oid);
      }
      elseif ($aid && $oid) {
        return uc_option_image_load(0, 0, 0);
      }
    }
  }
  return $files[$filename];
}