В модуле JAbulletin есть один баг... Он заключается в том, что он создает иконки для статьи только в том случает, если оригинал картинки находится на этом же сервере, а если вы в статье используете изображение с расположенное на другом сайте, то иконка не создастся.
Что бы научить этот модуль создавать иконки с картинок расположенных на других сайтов следует немного изменить функцию в файле helper.php который находится в папке modules/mod_jabulletin.
В конец файла перед вторыми фигурными скобками вставляем следующую функцию:
function jaResize2($image,$max_width,$max_height){
$path = JPATH_SITE;
$sizeThumb = getimagesize($image);
$width = $sizeThumb[0];
$height = $sizeThumb[1];
if(!$max_width && !$max_height) {
$max_width = $width;
$max_height = $height;
}else{
if(!$max_width) $max_width = 1000;
if(!$max_height) $max_height = 1000;
}
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if (($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
} else if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
} else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}
// read image
$image2=basename($image);
$ext = strtolower(substr(strrchr($image2, '.'), 1)); // get the file extension
$rzname = strtolower(substr($image2, 0, strpos($image2,'.')))."_{$tn_width}_{$tn_height}.{$ext}"; // get the file extension
$resized = $path.'/images/resized/'.$rzname;
if(file_exists($resized)){
$smallImg = getimagesize($resized);
if (($smallImg[0] <= $tn_width && $smallImg[1] == $tn_height) ||
($smallImg[1] <= $tn_height && $smallImg[0] == $tn_width)) {
return "images/resized/".$rzname;
}
}
if(!file_exists($path.'/images/resized/') && !mkdir($path.'/images/resized/',0755)) return '';
$folders = explode('/',$image2);
$tmppath = $path.'/images/resized/';
for($i=0;$i < count($folders)-1; $i++){
if(!file_exists($tmppath.$folders[$i]) && !mkdir($tmppath.$folders[$i],0755)) return '';
$tmppath = $tmppath.$folders[$i].'/';
}
switch ($ext) {
case 'jpg': // jpg
$src = imagecreatefromjpeg($image);
break;
case 'png': // png
$src = imagecreatefrompng($image);
break;
case 'gif': // gif
$src = imagecreatefromgif($image);
break;
default:
}
$dst = imagecreatetruecolor($tn_width,$tn_height);
//imageantialias ($dst, true);
if (function_exists('imageantialias')) imageantialias ($dst, true);
imagecopyresampled ($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height);
imagejpeg($dst, $resized, 90); // write the thumbnail to cache as well...
return "images/resized/".$rzname;
}
Далее находим функцию function resizeImage и заменяем ее на следующее:
function resizeImage ( &$img, $width, $height ) {
if(!$img) return '';
if (!function_exists ('imagejpeg')) return $img;
$img2=$img;
$img = str_replace(JURI::base(),'',$img);
$img = rawurldecode($img);
$img2 = rawurldecode($img2);
$imagesurl = (file_exists(JPATH_SITE .'/'.$img)) ? JURI::base().JAImageTools::jaResize($img,$width,$height) : JURI::base().JAImageTools::jaResize2($img2,$width,$height);
//$imagesurl = jaResize($img,$width,$height);
return $imagesurl;
}
Сохраняем файл.
После этого модуль сможет работать с любыми изображениями.