HIRE US

Let us help you with your Drupal requirements

To prevent automated spam submissions leave this field empty.

A Drupal user found out that the ImageCache preset folders were not being created after they had created the presets. If you are encountering the same situation in your Drupal site then continue reading for the solution.

Applying the following patched imagecache_create_url function will fix the issue.

function imagecache_create_url($presetname, $filepath, $bypass_browser_cache = FALSE, $absolute = TRUE) {
  $args = array('query' => empty($bypass_browser_cache) ? NULL : time());
  $file_directory = file_directory_path();

  // Determine the path of the derivative inside the files directory.
  $derivative_path = 'imagecache/'. $presetname .'/'. _imagecache_strip_file_directory($filepath);

  // Then construct a full path and see if anyone wants to alter it.
  $altered_path = $old_path = $file_directory .'/'. $derivative_path;
  drupal_alter('file_url', $altered_path);

  // If any module has altered the path, then return the alteration...
  if ($altered_path != $old_path) {
    // ...but use url() so our $bypass_browser_cache parameter is honored.
    return url($altered_path, $args);
  }

  // It was unchanged so use the download method's prefix.
  $prefix = array(
    FILE_DOWNLOADS_PUBLIC => $file_directory,
    FILE_DOWNLOADS_PRIVATE => 'system/files',
  );
  $path = $prefix[variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)] .'/'. $derivative_path;

  // Temporarily turn off clean urls setting by default.
  global $conf;
  $bk = $conf['clean_url'];
  $conf['clean_url'] = 0;

  $rs = url($path, $args + array('absolute' => $absolute));

  // Restore clean urls setting.
  $conf['clean_url'] = $bk;

  return $rs;
}

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. Do you need professional help in building your Drupal site? We can provide a wide range of Drupal services to help you deploy your Drupal site easily and quickly. Get in touch with us to know more.

Post your comments / questions