MyBB Community Forums

Full Version: wrap img with a div ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi

i want to add a little bit security to my forum images so i want to wrap the [img] with a div to make it something like that :

<div style="height: auto; overflow: hidden;">
  <img src="[img]" alt="your image" />
</div>

is it possible ?

thanks
I don't understand why you want do this but here is a way how:

Add a new custom MyCode in ACP > Configuration:
MyCode: Image Wrote:Title: IMG Tag

Short Description: Style IMG Tag

Regular Expression:

\[img\](.*?)\[/img\]

Replacement:

<div style="height: auto; overflow: hidden;"><img src="$1" alt="your image" /></div>
thanks , but my code is not working i want to prevent my forum images from saving
^ we can't prevent copying / saving images.
i know but at least make it harder to copy
If you want it to be really tricky, you could have the image url be the background-image property of a div.

Ex.
Regex: \[img\](.*)\.(png|jpg|bmp|gif)\[\/img\]
Replacement: <div style="background-image: url($1$2)"><img src="$1$2" alt="image" style="visibility:hidden" /></div>

Visbility:hidden is used so it tricks the div into figuring out how much space to allot. You may need quotes around $1 and $2 in the parenthesis.
(2015-01-22, 03:39 PM)dragonexpert Wrote: [ -> ]If you want it to be really tricky, you could have the image url be the background-image property of a div.

Ex.

Regex: \[img\](.*)\.(png|jpg|bmp|gif)\[\/img\]
Replacement: <div style="background-image: url($1$2)"><img src="$1$2" alt="image" style="visibility:hidden" /></div>

Visbility:hidden is used so it tricks the div into figuring out how much space to allot.  You may need quotes around $1 and $2 in the parenthesis.


wow your so smart i tried one day to figure out how to size the div to match the pic bu t i couldnt thanks mate !!

oops another error came i edited your code a little bit and know it doubles the image

Regular EXP: \[img\](.*?)\[/img\]
Replacement:
<div style="background-image: url($1)"><img src="$1" alt="وێنە" style="visibility:hidden" /></div>
Try this:

Regular EXP:
\[img\](.*?)\[\/img\]

Replacement:
<div style="background: url($1) no-repeat;display:inline-block;"><img src="$1" alt="وێنە" style="visibility:hidden" /></div>
Thank you guys you all helped me alot Smile thank you SvePu +1 and dragonexpert +1