FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Use getimagesize on an attached file from postproc.inc.t
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Use getimagesize on an attached file from postproc.inc.t [message #162724] Thu, 08 July 2010 11:00 Go to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
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!


[Updated on: Thu, 08 July 2010 11:02]

Report message to a moderator

Re: Use getimagesize on an attached file from postproc.inc.t [message #162725 is a reply to message #162724] Thu, 08 July 2010 12:13 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
I worked around it by adding new BBcode tags instead.

Re: Use getimagesize on an attached file from postproc.inc.t [message #162730 is a reply to message #162725] Sat, 10 July 2010 07:17 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Did you write it as a plugin? if so, can you please share it with us?

BTW, If you belief there is a bug in the code, please post a test case/procedure (with unmodified code) so we can look into it.
Re: Use getimagesize on an attached file from postproc.inc.t [message #162734 is a reply to message #162724] Sat, 10 July 2010 09:15 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
I am running 2.7.7++ so there is no plugin support =(

The new BB code I made is just a quick fix workaround, where if you use IMGM it inserts an image and defines its width to 300 - not a very pretty fix, but it worked for my purpose, but it's nothing that I think is worth sharing.


Re: Use getimagesize on an attached file from postproc.inc.t [message #162746 is a reply to message #162734] Sun, 11 July 2010 08:26 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
You can also do it in CSS. Juts add the following code to your forum.css.tmpl template and recompile your theme:
img {
   max-width: 450px;
}
Re: Use getimagesize on an attached file from postproc.inc.t [message #162747 is a reply to message #162746] Sun, 11 July 2010 08:27 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
If you run HTML 4.01 Transitional like I do, max-width is not supported by IE 7.

[Updated on: Sun, 11 July 2010 08:30]

Report message to a moderator

Re: Use getimagesize on an attached file from postproc.inc.t [message #162748 is a reply to message #162747] Sun, 11 July 2010 08:32 Go to previous message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
But damn it, you are right, I am gonna use that also. I noticed it was supported in many more browsers now - My own fault for not keeping up with the times =(

  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Mailing list integration
Next Topic: Removing disclaimers from mailing list synced postings
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 19:35:34 GMT 2024

Total time taken to generate the page: 0.02839 seconds