Search code examples
phpimageresizeforumstretch

Resizing images


I'm working on a forum application in PHP. In signature field I have
"<img src='randomimage.png'><br>bla blah"

If an image is bigger than the field it stretches my tables and looks bad. Is there any way to re size the image if its too big?

Sorry for my poor English and thank you for reading

Edit: The thing is that it's not only the image. It's the image and the text "the big text".

Respectfully, Tom


Solution

  • PHP...

    You can re-size images with the gdlibrary (See: PHP/GD - Cropping and Resizing Images), but that may be complicated if you're not already pretty familiar with PHP.

    jQuery/Javascript

    A plugin exists that can dynamically resize images (stretching the image itself). Check out maxSide: http://css-tricks.com/maxside-jquery-plugin-and-how-to/

    CSS...

    A quick-solution for keeping the signature imaged tamed is to restrict their overflow with css:

    <img src="randomimage.png" />
    

    Becomes

    <div class="sigBox"><img src="randomimage.png" /></div>
    

    With the following CSS:

    div.sigBox { overflow:hidden; width:50px; height:50px; }
    

    This will hide large images, rather than allowing them to distort your content.