TinyMCE image manager plugin "Archiv"
I am using the TinyMCE image manager plugin Archiv.
I configured as recommended
in config.base.php, if I set
'upload_path' => '/var/www/example/template/',
'upload_uri' => 'http://www.example.com/template/',
it works fine, but if I use:
'upload_path' => $upload_path,
'upload_uri' => $upload_uri,
where
$dir = $client->agencycode; //which is string
$upload_pa开发者_JAVA技巧th = "/var/www/example/template/$dir/";
$upload_uri = "http://www.example.com/template/$dir/";
The plugin work properly except uploading files. I can create directory, list directory, delete files. The only thing do not work is upload a files.
Is there anyway or anything need to configure in order to make uploads work?
Thanks.
If you have problems with a Black background while uploading transparent png files, change the function create_png(...)
in Archiv->php->connector
to the following code:
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);
}
Finally, I used the 'images' plugin instead. As other mentioned, there is no documentation for this plugin.
精彩评论