I have a bbcode parser that turns,
[img]imageurl[/img]
bbcodes into,
<img src="imageurl" alt="" />
The only problem is, I want to be able to enforce a maximum width and maximum height on these images without messing up the aspect ratio, but I can开发者_如何学Cnot check the size and do resizing math before hand since the bbcode parser is not that smart. Is there a way to enforce an aspect ratio respecting maximum size of an image without any knowledge of the image's dimensions using inline css or javascript?
I know I could change the bbcode parser to set a maxwidth for the tag's style, but this does not seem to work on IE6.
use css:
img {
max-width:30em;
max-height:10em;
}
probably combine with a container, so you only have images inside your bbcoded posts max-sized instead of every image on your site:
div.post img { … }
I am not sure if it possible to do it client-side AND support IE 6(Why in heavens would you want to?) AND support modern browsers without a ton of hoop-jumping, nasty Javascript or CSS.
Is there a reason you can't do it server-side? You are going to have to do some sort of validation server-side since javascript and css are easily removed/shut off.
精彩评论