TinyMCE图像管理器插件“Archiv”

时间:2011-08-11 09:19:06

标签: tinymce

我使用的是TinyMCE图像管理器插件 Archiv

我配置为推荐

在config.base.php中

,如果我设置

'upload_path'           => '/var/www/example/template/', 
'upload_uri'            => 'http://www.example.com/template/',

它工作正常,但如果我使用:

'upload_path' => $upload_path,
'upload_uri' => $upload_uri,

其中

$dir = $client->agencycode;  //which is string 
$upload_path = "/var/www/example/template/$dir/";
$upload_uri = "http://www.example.com/template/$dir/";

除上传文件外,插件工作正常。 我可以创建目录,列表目录,删除文件。唯一不起作用的是上传文件。

无论如何还是需要配置才能使上传工作?

感谢。

2 个答案:

答案 0 :(得分:1)

如果您在上传透明png文件时遇到黑色背景问题,请将create_png(...)中的Archiv->php->connector功能更改为以下代码:

function create_png($file, $width, $height, $pic_new_width, $pic_new_height, $thumb_width, $thumb_height){
        #fetch the extention from the file
        $file_path  = substr($file,0,strrpos($file,DIRECTORY_SEPARATOR));
        $file_name  = substr($file,strlen($file_path)+1, (strrpos($file,".")-(strlen($file_path)+1)));
        $file_ext   = substr($file,strrpos($file,"."));

        #create the picture
        $pic            = imagecreatetruecolor($pic_new_width, $pic_new_height);
        $source         = imagecreatefrompng($file);


        // enable alpha blending on the destination image.
        imagealphablending($pic, true); 

        // Allocate a transparent color and fill the new image with it.
        // Without this the image will have a black background instead of being transparent.
        $transparent = imagecolorallocatealpha( $pic, 0, 0, 0, 127 );
        imagefill( $pic, 0, 0, $transparent );


        $imgcpyrsmpld   = imagecopyresampled( $pic, $source, 0, 0, 0, 0, $pic_new_width, $pic_new_height, $width, $height );

        imagealphablending($pic, false); 

        // save the alpha
        imagesavealpha($pic,true); 

        header('Content-type: image/png'); 

        if(version_compare(PHP_VERSION, '5.1.2', '<')){
            $imagepng   = imagepng($pic, $file_path.DIRECTORY_SEPARATOR.$file_name.$file_ext);
        }
        else{
            $imagepng   = imagepng($pic, $file_path.DIRECTORY_SEPARATOR.$file_name.$file_ext, 0);
        }       

        $imagedestroy   = imagedestroy($pic);

        list($width, $height) = @getimagesize($file);

        #create the thumb
        $thumb              = imagecreatetruecolor($thumb_width, $thumb_height);
        $source2            = imagecreatefrompng( $file );      

        // enable alpha blending on the destination image.
        imagealphablending($thumb, true); 

        // Allocate a transparent color and fill the new image with it.
        // Without this the image will have a black background instead of being transparent.
        $transparent = imagecolorallocatealpha( $thumb, 0, 0, 0, 127 );
        imagefill( $thumb, 0, 0, $transparent );

        $imgcpyrsmpld2      = imagecopyresampled( $thumb, $source2, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height );

        imagealphablending($thumb, false); 

        // save the alpha
        imagesavealpha($thumb,true); 

        header('Content-type: image/png'); 

        if(version_compare(PHP_VERSION, '5.1.2', '<')){
            $imagepng2      = imagepng($thumb, $file_path.DIRECTORY_SEPARATOR.$file_name.'_thumb'.$file_ext);
        }
        else{
            $imagepng2      = imagepng($thumb, $file_path.DIRECTORY_SEPARATOR.$file_name.'_thumb'.$file_ext, 0);
        }

        $imagedestroy2      = imagedestroy($thumb);
    }

答案 1 :(得分:0)

最后,我使用了'images'插件。 正如其他人提到的,这个插件没有文档。