DJTim666 Posted September 25, 2007 Share Posted September 25, 2007 How can I stop an image from stretching a table? I am allowing users to use BBCode to add images to their profiles/forum signature, and if the image is big it stretches the table and makes everything look like crap. Does anyone know of a way to stop this? Or would i just have to limit the width upon inserting it into the database? This is the preg_replace I am using for images... <?php $done = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src="$1">', $done); ?> Any suggestions? -- DJ Quote Link to comment Share on other sites More sharing options...
EvanAgee Posted September 25, 2007 Share Posted September 25, 2007 One quick idea is to add a <div> around their signature area (or use the div that's already there, if applicable) and then use css to set a maximum width for the div. Obviously you could also add some code to look at the image they're trying to input and return an error if they try and use an image that's too large. However, if you don't have much PHP knowledge that might be a little difficult. Here's the <div> code just in case you decide to go that route: <div style="max-width: XXXpx; overflow: hidden;">IMAGE BB CODE HERE</div> Please note that the max-width css property has limited to no support in IE 6-. If your design uses a fixed width I would specify that instead, for better browser support. <div style="width: XXXpx; overflow: hidden;">IMAGE BB CODE HERE</div> Hope that helps. Quote Link to comment Share on other sites More sharing options...
DJTim666 Posted September 25, 2007 Author Share Posted September 25, 2007 I have a very good knowledge of PHP which is why this 'was' posted on the PHP Help board. I wanted to know how to limit it in PHP. The CSS could be helpful for the actual post message though. Thanks for that. Could you please explain limiting with PHP =D. -- DJ Quote Link to comment Share on other sites More sharing options...
DJTim666 Posted September 25, 2007 Author Share Posted September 25, 2007 Wow, I never knew CSS was so powerful. I guess I can use CSS to limit these things. Thank you VERY much Evan. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.