Jump to content

BBcode Image dimmension restrictions???


Recommended Posts

Hey i have something on my game when players can make like biography/journal/diary whatever u wanna call it, and they can use bbcode, and i know most people just dont allow images but come on what player dont like to share images xDD BUT i dont want anyone to post any humongous image and mess things up, so is it a way to put a limit on the dimmensions of images posted using bbcode?

Link to comment
Share on other sites

Well I imagine, you convert [.img][./img] into <img>, so apply width/height limits to the img tag (the browser does an okay job a resizing images), this saves creating a copy on your server and manually 'looping through all images'.

If you want to get clever, you can modify your bbcode parser to allow you specify whether or not you want to apply dimension limits on images and specify what the dimensions you desire.

(Doesn't change the above fact)

*Is to lazy to post code examples, so he lets Bluegman991 do it. :p VV

Edited by Djkanna
Link to comment
Share on other sites

What DJK said^^

You could create a css class like this: (changing max width/height to whatever you prefer)

img.bbimg {


and add


to the img tag.

ohhhh that makes sooooooo much sense thanx everyone! dont know what i would do without this forum ^_^

Link to comment
Share on other sites

max-width and min-width along with a jQuery fallback is probably your best bet.

Then it will work with all browsers.

$('.bbimg').each(function() {
if($(this).width() > 500) { $(this).width(500); }

Something like that, it's early so probably won't work.

Link to comment
Share on other sites

There are hacks in making it work in all browsers, however you would need to find them on google because there is many ways in doing it. I would post, but last time I did someone picked my post apart, so trying to refrain from doing so.

There is also the code facebook uses floating around to on google.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...