You are here

function imagecache_external_generate_path in Imagecache External 7

Same name and namespace in other branches
  1. 8 imagecache_external.module \imagecache_external_generate_path()
  2. 6.2 imagecache_external.module \imagecache_external_generate_path()
  3. 7.2 imagecache_external.module \imagecache_external_generate_path()

Util to generate a path to an image

Parameters

$url string the url to the image:

$preset imagecache preset:

Return value

string the url to the image

1 call to imagecache_external_generate_path()
theme_imagecache_external in ./imagecache_external.module
Returns HTML for an image using a specific image style.

File

./imagecache_external.module, line 118

Code

function imagecache_external_generate_path($url, $preset) {

  // Create the extenal images directory and ensure it's writable.
  $hash = md5($url);
  $scheme = file_default_scheme();
  $directory = $scheme . '://imagecache/' . $preset . '/externals/' . $hash;
  if (file_prepare_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
    $file = imagecache_external_fetch($url, $directory);
    if ($file) {
      return $file->uri;
    }
  }

  //we couldn't get the file
  return FALSE;
}