dongya1228 2012-05-06 11:25
浏览 30
已采纳

drupal imagecache模块只适用于'默认'网站?

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 =)

  • 写回答

1条回答 默认 最新

  • doudeng5764 2012-05-24 17:44
    关注
    <?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
               );
           }
    } ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题