Jump to content

Problem displaying pictures


xcandiottix

Recommended Posts

I have a code that loads a picture up for display. The picture size is first checked and if it is too big it is resized via html height and width. Here's the display image code:

 

echo '<center><img src="http://www.msormr.com/upload/'.$showpic.'" height="'.$newHeight.'" width="'.$newWidth.'"></center>';

 

In google chrome it works fine. I was going on with design when I friend noted that he couldn't see any of my images. I opened IE and found this to be true. At first I realized I had my height and width tags in reverse order but fixing that hasn't helped. Any suggestions??

 

Thanks,

K.candiotti

Link to comment
https://forums.phpfreaks.com/topic/197596-problem-displaying-pictures/
Share on other sites

I don't think so... my second image is

 

45gf4g545.jpeg

 

I just checked in firefox and things look good there too. Maybe my IE is out of date, I'll check that next. It seems to be my resizing code. Some of the images are showing up as the correct height but only 1 pixel wide. Again, in firefox and chrome all is well.

 

Here's my resizing code:

 

//constrain size main img

$whichimage = /upload/".$showpic."";

$wistring = str_replace(" ", "%20", $whichimage);

$whichimage = $wistring;

list($width, $height)= getimagesize($whichimage);

if ($height > 600){

$ratio = 600 / $height;

$newHeight = $height * $ratio;

$width = $width * $ratio;

}

if ($width > 800){

$ratio = 800 / $width;

$newWidth = $width * $ratio;

$newHeight = $newHeight * $ratio;

}

 

I just uploaded a pic to your website, and in Safari it displayed just fine, but here is the source HTML. Note that the <img> tag is not closed before the <br />. That is probably what is cratering IE.

<td align="center" valign="top">
<img src = "http://www.msormr.com/upload/Condi_rice.jpg"<br /><br />
<span class="Blue">Here's your uploaded image but you're not done yet. Make sure to check your e-mail for the confirmation link so this image can be rated.</span></td>

Well i'm an idiot too. Check this out:

 

//constrain size main img

$whichimage = "http://www.msormr.com/upload/".$showpic."";

$wistring = str_replace(" ", "%20", $whichimage);

$whichimage = $wistring;

list($width, $height)= getimagesize($whichimage);

if ($height > 600){

$Hratio = 600 / $height;

$newHeight = $height * $Hratio;

$width = $width * $Hratio;

}

else

{

$newHeight = $height;

}

if ($width > 800){

$Wratio = 800 / $width;

$newWidth = $width * $Wratio;

$newHeight = $newHeight * $Wratio;

}

else

{

$newWidth = $width;

}

 

 

Otherwise, if the picture is with in constraints it never gets set to $new height or width. Therefore when it's asked for in

 

    echo '<center><img src="/upload/'.$showpic.'" height="'.$newHeight.'" width="'.$newWidth.'"></center>';

 

it doesn't have a size.

 

I think this fixed it!

I just uploaded a pic to your website, and in Safari it displayed just fine, but here is the source HTML. Note that the <img> tag is not closed before the <br />. That is probably what is cratering IE.

<td align="center" valign="top">
<img src = "http://www.msormr.com/upload/Condi_rice.jpg"<br /><br />
<span class="Blue">Here's your uploaded image but you're not done yet. Make sure to check your e-mail for the confirmation link so this image can be rated.</span></td>

 

 

Ahhh you're right there too! That's a separate page that doesn't run resizing but good catch none the less! =)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.