Use getimagesize on an attached file from postproc.inc.t [message #162724] |
Thu, 08 July 2010 11:00 |
Ernesto
Messages: 413 Registered: August 2005
Karma:
|
Senior Member |
|
|
I have this code:
<?php case 'img':
case 'imgl':
case 'imgr':
if (!$allow_img) {
$ostr .= substr($str, $pos, ($cepos-$pos)+1);
} else {
$class = ($tag == 'img') ? '' : 'class="'.$tag{3}.'" ';
$img_maxwidth = 600;
if (!$parms) {
$parms = substr($str, $epos+1, ($cpos-$epos)-1);
list($imgw, $imgh) = getimagesize(url_check($parms));
if ($imgw > $img_maxwidth) {
$img_ratio = $imgw/$img_maxwidth;
$imgw = $img_maxwidth;
$imgh = round($imgh/$img_ratio);
}
if (strpos(strtolower(url_check($parms)), 'javascript:') === false) {
if ($img_ratio <= 1)
$ostr .= '<img '.$class.'src="'.$parms.'" style="width:'.$imgw.'px; height:'.$imgh.'px;" border="0" alt="'.$parms.'">';
else
$ostr .= '<img alt="Click to view full-size" '.$class.'src="'.$parms.'" onclick="return hs.expand(this, {allowSizeReduction: false, src: this.src})" class="highslide" style="width:'.$imgw.'px; height:'.$imgh.'px;" border="0">';
else
$ostr .= '<img alt="Click to view full-size" '.$class.'src="'.$parms.'" onclick="return hs.expand(this, {allowSizeReduction: false, src: this.src})" class="highslide" style="width:'.$imgw.'px; height:'.$imgh.'px;" border="0">';
} else {
$ostr .= substr($str, $pos, ($cepos-$pos)+1);
}
} else {
if (strpos(strtolower(url_check($parms)), 'javascript:') === false) {
list($imgw, $imgh) = getimagesize(url_check($parms));
if ($imgw > $img_maxwidth) {
$img_ratio = $imgw/$img_maxwidth;
$imgw = $img_maxwidth;
$imgh = round($imgh/$img_ratio);
}
if ($img_ratio <= 1)
$ostr .= '<img '.$class.'src="'.$parms.'" style="width:'.$imgw.'px; height:'.$imgh.'px;" border="0" alt="'.substr($str, $epos+1, ($cpos-$epos)-1).'">';
else
$ostr .= '<img alt="Click to view full-size" '.$class.'src="'.$parms.'" onclick="return hs.expand(this, {allowSizeReduction: false, src: this.src})" class="highslide" style="width:'.$imgw.'px; height:'.$imgh.'px;" border="0">';
} else {
$ostr .= substr($str, $pos, ($cepos-$pos)+1);
}
}
}
$epos = $cepos;
$str[$cpos] = '<';
break; ?>
The code works on regular images, however, when the image inside the tags is an attachment, IE index.php?getfile=123&private=0 it doesn't work.
I tried to write the script in a separate PHP file to see if perhaps it didnt work with getimagesize() on a dynamic php file, but it works just perfect.
So, my conclusion is that somehow the getfile.php script isnt executed when running post_proc for some reason and I would love to know how I can take care of this!
I could walk around this and create a new BB code tag that allows me to specify img dimensions, but that feels unecessary!
So, any help provided is appreciated!
Ginnunga Gaming
[Updated on: Thu, 08 July 2010 11:02] Report message to a moderator
|
|
|