MyBB Community Forums

Full Version: Mycode to display image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can anyone make a mycode to just display an image when we use the single code tag like posting the below single start tag
[image]
displays an image instead of it.
Do you want to dispaly a specific image using the [image] tag or allow the user to choose ?
display specific static image, not for users.
To set a default image
Regular Expression:
\[image(.*?)\]

Replacement:
<img  src="your image link here"  />

Usage:
[image]


Let a user choose the image
Regular Expression:
\[image=(.*?)\]

Replacement:
<img  src="$1"  />

Usage:
[image=http://your image link here]
thanks jonato, the first worked like charm, but the second didnt worked well.
i tried this

Regex:
\[image2=(.*?)\]

replace:
<img  src="$1"  />

usage:
[image2=http://i208.photobucket.com/albums/bb168/BOptiz/wp.png]

and also can we use other code instead of this (.*?) in regex?
(.*?) poses security risk if not used properly.
used this regex:

\[image=(?)\]

i expect this will work at all places and doesnt pose the security risk of using (.*?)
...for the second one you could just use the built in [img][/img] mycode...
[img]http://image.url.here[/img]
Yes, you are right, Splappy.
But if you want to wrap some code around the posted image? Then you must take help of mycode.

when someone post the custom mycode as [image="image url"] without endtags will display your image and if you want to add some default text, borders or something, you can simply add them to the replacement as
<span style="border: 5px solid #456434; padding: 6px; font-family: arial; font-size: 15px;">This is the image<br /><img  src="$1"  /></span>

------------

yaldaram, it worked fine. but i had a doubt. if we use (?) instead of (.*?) in regex works?
check this "The MyCode posted is vulnerable to XSS attack: http://mybbhacks.zingaburga.com/showthre...89#pid4089 "
i used just (?) and it worked. hope it will work at every place without any problem??