PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$array = getimagesize('/path to file');
if ($array[0] > 525) { // width is 526 or higher
?>
HTML IMG TAG with 525 width
<?php
}
else // width is 525 or less
?>
HTML IMG TAG full size image with
<?php
}
?>
and for future info, $array[1] is height
$array[3] is height="yyy" width="xxx" that can be used directly in img tag
Last edited by LuaMadman on Tue Jul 20, 2010 8:54 am, edited 1 time in total.
Thanks LuaMadman so far you have really helped me.
I have changed my code to this. I noticed you missed a semi colon after the path. For the images smaller then 525 the code works perfectly, but for the images above that width they just go full size on my screen as if they have bypassed the first the IF statement.
WRONG!
auto tells the html to use the size image is
width="auto" height="auto" should be width="525" height="auto" or width=525 height="auto" depending on how you choose to code...
*edit*
Thanks for noticeing the missing ;
i'll edit my post.
*edit2*
my bad.
missed that you did some changes in the code.
Above is wrong.
width="auto" height="auto" is correct
it's the 100% that should be change 100% means 100% of the webpage or the table it's in.
so change 100% to 525
my bad.
missed that you did some changes in the code.
Above is wrong.
width="auto" height="auto" is correct
it's the 100% that should be change 100% means 100% of the webpage or the table it's in.
so change 100% to 525
I knew what you meant , I tried both. They still dont work. they just run the first statement.
This is the code i tested on my computer. It works for me.
i noticed that you use getimagesize('$path'); that failed for me, getimagesize($path); works.
Well, I'm off work now. If you don't get it working, I can't help you untill tomorrow
Good luck!