我有多站点设置,其中imagecache模块位于sites / all下。我的目标是让每个站点都有自己的imagecache文件夹,其中包含属于该站点的请求;例如通过domain1 / imagecache / files / thumb_image / photos / bigavatar.jpg引用它们。
照片文件夹已通过FTP上传,因此drupal基本上不知道它(数据库方式),但如果文件夹位于sites / default / files / photos下并且默认情况下引用/ imagecache / files / thumb_image,则imagecache功能完美/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
Splendid =)
答案 0 :(得分:0)
<?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
);
}
} ?>