Hi,

I'm using the asset module and I need 4 imagecache versions of every asset all the time. I'm having problems with this.
Is there a way to call imagecache directly without calling the theme function?

Any help would be great.

regards, Logi

Comments

Logi-1’s picture

Well what you do is use the imagecache_build_derivative() function. In the asset module I added this:

if (function_exists('theme_imagecache') && substr($imagecache, 0, 11) =="imagecache:")
{
//Normal asset imagecache function
list($imagecache, $preset) = split(":", $imagecache);
$img = theme('imagecache', $preset, $a->filepath, $asset['caption'], $asset['caption']);

//Here we will build new preset versions using all available presets
$allformatters = imagecache_presets();
foreach($allformatters as $format)
{
//lets get the preset
$realPreset = imagecache_preset_by_name($format[presetname]);
//get the actions for the preset
$actions_for_preset = imagecache_preset_actions($realPreset);
//get the path of the file without the "files"
$chopedPath = str_replace( file_directory_path(), '', $a->filepath);
//find the correct folder
$dst = file_directory_path() .'/imagecache/'.$format[presetname]. $chopedPath;
//build the imagecache image
imagecache_build_derivative($actions_for_preset, $a->filepath, $dst);
}
}

I hope that helps somebody.

regards, Logi

drewish’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.