>我有多站点设置,其中图像缓存模块驻留在站点/全部下。我的目标是让每个站点都有自己的图像缓存文件夹,其中包含属于该站点的请求;例如,通过domain1/imagecache/files/thumb_image/photos/bigavatar.jpg引用它们。
照片文件夹是通过FTP上传的,所以drupal基本上不知道它(数据库方面(,但如果文件夹位于站点/默认/文件/照片下并且默认引用/imagecache/files/thumb_image/photos/bigavatar.jpg,则图像缓存功能完美。
寻找设置选项 - 并发现如果更改了站点的上传路径,则 imagecache 将使用它,但是;对于我的(JS(图像存储,发送到我的画廊,存储数据来自我自己的模块ximagegallery。路径的生成方式如下:
<?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 仅适用于文件系统配置的上传路径,我希望超越这一点并使 imagecache 响应任何位置,例如如果两个站点需要共享一个公共图库/图像文件夹。
编辑; 我认为一个解决方案是创建另一个hook_menu,从我的派生模块调用 imagecache 函数 - 因为它是一个依赖项,这对于我猜的目的来说足够模块化
<?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
);
}
} ?>
如果我的文件夹钩子包含"domain2/foo/bar",那么这允许使用 http://domain.tld/drupal/?q=domain2/foo/bar/imagecache/myimagefolder/galleryid/photo.jpg
灿烂 =(
<?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
);
}
} ?>