Jump to content

[SOLVED] Images


DJTim666

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/70553-solved-images/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/70553-solved-images/#findComment-354513
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/70553-solved-images/#findComment-354514
Share on other sites

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.