imagecache folder and files outside the drupal installation path

headkit - June 26, 2008 - 17:30
Project:ImageCache
Version:5.x-2.0
Component:Code
Category:support request
Priority:critical
Assigned:headkit
Status:active
Description

hi!

i try to make imagecache save its generated files outside the drupal installation path.
i changed the system files path to "../" and i changed the imagecache file path with a theming function in template.php like

function blackborder_imagecache($namespace, $path, $alt = '', $title = '', $attributes = NULL) {
  $attributes = drupal_attributes($attributes);

  if (module_exists('transliteration')){
$pathlength = strlen(file_directory_path());
$splitted = substr(transliteration_get($path), $pathlength);
$imagecache_path = file_create_url(file_directory_path().'/imagecache/'. $namespace .$splitted);

  }else{
  $imagecache_path = file_create_url(file_directory_path() .'/imagecache/'. $namespace .'/'. $path);
  }
  return '<img src="'. $imagecache_path .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $attributes .' />';
}

but how could i make imagecache write its files to this path?
"../files/imagecache/namespace/images/"

can someone help me?

#1

drewish - June 28, 2008 - 22:24

imagecache isn't designed to write it's files outside of drupal's files directory. i don't think you're going to be able to get it to work without some hacking.

#2

headkit - June 29, 2008 - 14:11

i would be fine with that.
but at which end shoul i hack the module. i don't find the code which starts the filecreation...

#3

guardian - June 29, 2008 - 20:56

i offered a patch allowing to change the path where imagecache stores the derivatives: http://drupal.org/node/251597

the first version of the patch allowed to stored files anywhere
then another version was made in order to comply with http://drupal.org/node/66763

however in the end, it is still undecided whether or not imagecache should be allowed to store the derivatives anywhere; according to dopry nothing forbids it

#4

headkit - June 30, 2008 - 12:46

i will try that.
big thanx, man!

#5

headkit - July 1, 2008 - 15:22

o.k. which one exactly allows a path leading to anywhere?

i tried the latest of your patches from that link and i can change the path of imagecache now. thats nice and it creates the imagecache folder outside the installationpath of drupal, but it does not create a preset-folder and no image file.

please help,
thnx!!!

#6

headkit - July 9, 2008 - 13:03

no hints?

#7

guardian - July 9, 2008 - 17:34

the patch attache to this comment: http://drupal.org/node/251597#comment-822602 used to offer the functionality you need

however, since then, imagecache's code evolved and the patch doesn't apply anymore

the patch attached to http://drupal.org/node/251597#comment-866944 is more recent and may still apply but it forces the derivative files to be under the "files/" directory

i would say a decision has to be taken whether or not it is safe to allow derivative files outside "files/"

 
 

Drupal is a registered trademark of Dries Buytaert.