1 amorangi May 25, 2004 09:07
3 edb May 25, 2004 20:14
I just added this to the appropriate file and got the following error:
Warning: getimagesize(http://wonderwinds.com/blog/media/glassoff518b.jpg): failed to open stream: HTTP request failed! in /home/wonderw/public_html/blog/admin/b2upload.php on line 145
It worked sort of. The image uploaded but the text provided to insert into the post was "...... width="" height="" ......." It also took a heck of a long time to decide on the error and finish it's task, if that's a clue. Any idea where I should check on what for why?
4 amorangi May 26, 2004 01:16
It could be a bug in php.
5 edb May 26, 2004 02:30
I'll buy that - and talk to my host about it to see what they can do. In the mean time I decided to comment out the "getimagesize" line and remove the content it should provide from the "$piece_of_code" line. Cute variable name eh? That way it is providing me with spaces for the width and height parameters so I just type them in after placing the tag in the new post. It's not the best, but it works for me so I'll run with it until "getimagesize" behaves.
I also modified admin/b2upload to provide a class for the image. For the record I use the custom skin and I do not allow to skin switching. Other skins may or may not have these classes. In admin/b2upload.php at line 50:
<p><?php echo T_('Description') ?>:<br />
<input type="text" name="imgdesc" size="30" class="uploadform" /></p>
<p><?php echo T_('Select Class') ?>:<br />
<input type="radio" name="selectclass" class="uploadform" value="none">none
<input type="radio" name="selectclass" class="uploadform" value="top">top
<input type="radio" name="selectclass" class="uploadform" value="middle">middle
<input type="radio" name="selectclass" class="uploadform" value="left" checked>leftmargin
<input type="radio" name="selectclass" class="uploadform" value="right">rightmargin
</p>
The "Description" part is original - I added the "Select Class" radio buttons. Next is an addition immediately above the "getimagesize" piece that I had to comment out, and a change to the "$piece_of_code" deal.
if ($HTTP_POST_VARS['selectclass'] == "none") {
$imgclass = "";
}
if ($HTTP_POST_VARS['selectclass'] == "top") {
$imgclass = " class="top"";
}
if ($HTTP_POST_VARS['selectclass'] == "middle") {
$imgclass = " class="middle"";
}
if ($HTTP_POST_VARS['selectclass'] == "left") {
$imgclass = " class="leftmargin"";
}
if ($HTTP_POST_VARS['selectclass'] == "right") {
$imgclass = " class="rightmargin"";
}
if ( ereg('image/',$img1_type)) {
// $img_dimensions = getimagesize("$fileupload_url/$img1_name");
// $piece_of_code = "<img src="$fileupload_url/$img1_name" width="$img_dimensions[0]" height="$img_dimensions[1]" border="0" $imgclass alt="$imgdesc" />";
$piece_of_code = "<img src="$fileupload_url/$img1_name" width="" height="" border="0"$imgclass alt="$imgdesc" />";
} else {
$piece_of_code = "<a href="$fileupload_url/$img1_name" title="$imgdesc" />$imgdesc</a>";
};
?>
I then tweaked my CSS file a bit to push the last line beneath the image with a "clear: both;" added to bSmallHead (which is what is what I use for my little text under the posts). I then uploaded three images with only a little text associated with each and didn't like how it looked in Mozilla. Adding "bPost p { clear: both; }" to my CSS did the trick - the text typed in after each image stays with the image, and the bottom line of stuff goes beneath the last image.
Life is Good!
6 amorangi May 27, 2004 09:45
getimagesize is temperamental for me too it turns out.
It works fine on my test set up, but on my webhost it ALWAYS returns width="100" height="30"! >:( (only for jpg's - it works ok for gif's)
If anyone has a reason for this please let me know
7 vv12 Jun 23, 2004 21:26
I do a little more mod, now it is exactly wut i want, thx for u guys otherwise i have no idea wut place should i go to since i know nothing about php. :oops:
I just add a <a href> tag before that <img> tag if the size is bigger than expected and make a it thumb, then ppl can click on the thumb to view the whole pic. :D
if ( ereg('image/',$img1_type)) {
$img_dimensions = getimagesize("$fileupload_url/$img1_name");
if ($img_dimensions[0]>400) {
$img_width = 400;
$img_height = round($img_dimensions[1]*400/$img_dimensions[0]);
$piece_of_code = "<a href="$fileupload_url/$img1_name" target="_blank"><img src="$fileupload_url/$img1_name" width="$img_width" height="$img_height" alt="$imgdesc" /><br />Click to view original size<br /></a>";
}
else {
$piece_of_code = "<img src="$fileupload_url/$img1_name" border="0" alt="$imgdesc" />";
}
}
else {
$piece_of_code = "<a href="$fileupload_url/$img1_name" title="$imgdesc" />$imgdesc</a>";
};
8 kding Jul 11, 2004 21:12
Hi, I used the above code to detect and control image size. it worked well in first week. when uploaded image is too wide, a width=, and height= tag will be inserted. however, it seems not working any more. I checked the upload.php file, the code is still there. don't why. any ideas? thanks.
9 kellytps Jul 16, 2004 23:08
Thank you! It works wonderfully!
:)
Great. That's exactly what I also thought about yesterday and put it onto my todo for the media library.. until that gets done I'll put your code onto CVS.