Closed (fixed)
Project:
ImageCache
Version:
5.x-2.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Apr 2009 at 16:22 UTC
Updated:
13 May 2009 at 16:40 UTC
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
Comment #1
Logi-1 commentedWell 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
Comment #2
drewish commented