drupals imagecache module only works with 'default' site?
-
06-06-2021 - |
Frage
i have multisite setup where imagecache module resides under sites/all. My goal is for every site to have its own imagecache folder filled with requests, belonging to that site; e.g. referencing them by domain1/imagecache/files/thumb_image/photos/bigavatar.jpg.
The photos folder have been uploaded via FTP so drupal basically doesnt know about it (database-wise), but imagecache functions perfectly if the folder is under sites/default/files/photos and referenced by default/imagecache/files/thumb_image/photos/bigavatar.jpg.
Have looked for setting up options - and found that if the upload path is changed for a site, then imagecache would work with it but; For my (JS) store of images, sent to my gallery the store data comes from my own module, ximagegallery. This is how the paths are produced:
<?php
/**
* @param title : visible gallery title
* @param basename filename base of image
* @param site current site (commonly guessed from REQUEST_URI but goal is to let this be configurable)
* @param location path of $basename imagefile underneath sites/$site/
*/
function ximagegallery_get_object($title, $basename, $site, $location) {
return array(
"title" => $title,
"link" => "{$site}{$location}/{$basename}",
"screenpath" => "{$site}/imagecache/screen{$location}{$basename}",
"thumbpath" => "{$site}/imagecache/small_thumb{$location}{$basename}"
);
}
?>
Imagecache only works with the upload-path for the filesystem config, i wish to surpass this and make imagecache respond to any location, say if two sites needs to share a common gallery / imagefolder.
Edit; i figured a solution would be to create another hook_menu, calling the imagecache functions from my derived module - as its allready a dependency, this would be modular enough for the purpose i guess
<?php
function ximagegallery_menu() {
// standard route hook
$items['ximagegallery/store/%'] = array(
'title' => 'ximagegallery_GENERATE',
'page callback' => 'ximagegallery_generate_store',
'page arguments' => array(1),
'access callback' => 'ximagegallery_access'
);
// one hook for each configured path
$hooks = get_variable('ximagegallery_folderhooks', array());
foreach($hooks as $folder) {
$items['$folder.'/imagecache'] = array(
'page callback' => 'imagecache_cache',
'access callback' => '_imagecache_menu_access_public_files',
'type' => MENU_CALLBACK
);
}
} ?>
If my folderhooks contains 'domain2/foo/bar', then this allows using of http://domain.tld/drupal/?q=domain2/foo/bar/imagecache/myimagefolder/galleryid/photo.jpg
Splendid =)
Lösung
<?php
function ximagegallery_menu() {
// standard route hook
$items['ximagegallery/store/%'] = array(
'title' => 'ximagegallery_GENERATE',
'page callback' => 'ximagegallery_generate_store',
'page arguments' => array(1),
'access callback' => 'ximagegallery_access'
);
// one hook for each configured path
$hooks = get_variable('ximagegallery_folderhooks', array());
foreach($hooks as $folder) {
$items['$folder.'/imagecache'] = array(
'page callback' => 'imagecache_cache',
'access callback' => '_imagecache_menu_access_public_files',
'type' => MENU_CALLBACK
);
}
} ?>