Could it be possible to automatically resize an external image to a maximum width/height? I'm talking about the [img] tag. Sometimes my users publish a big image and it breaks the forum width completely. Thumbnailing would not be needed, only simple resizing, maybe with an attached message: "Click on image to see it full sized" or something like that.

Comments

naudefj’s picture

Assigned: Unassigned » naudefj
Priority: Normal » Minor

Unfortunately not. However, it would be a cool feature to add.

naudefj’s picture

Status: Active » Closed (works as designed)
gurukripa’s picture

could this feature be incorporated..has someone done it?

moksa’s picture

I want it too ! With a thickbox link will be great...
We need a get_size on the external image before image filter process... But how... I search...

    // Images without or with client-side sizing
    '#\[img(?::\w+)?\]([\w:;&,~%+!=@\/\.\-\#\?]+)\[/img(?::\w+)?\]#si' => '<img src="\\1" alt="" class="bb-image" />',
    '#\[img=(\d+)x(\d+)(?::\w+)?\]([\w:;&,~%+!=@\/\.\-\#\?]+)\[/img(?::\w+)?\]#si' => '<img width="\\1" height="\\2" alt="" src="\\3" class="bb-image" />',
    '#\[img=([\w\s:;,\.\-\'\(\)]+)(?::\w+)?\]([\w:;&,~%+!=@\/\.\-\#\?]+)\[/img(?::\w+)?\]#si' => '<img alt="\\1" src="\\2" class="bb-image" />',
    '#\[img align=(left|right|center)(?::\w+)?\]([\w:;&,~%+!=@\/\.\-\#\?]+)\[/img(?::\w+)?\]#si' => '<img src="\\2" alt="" align="\\1" class="bb-image" />',

++

moksa’s picture

Ok in bbcode-filter.inc i delete "// Images without or with client-side sizing" code.

and i replace with this added in line 30... we can imagine an imagecache resize etc etc...

if (preg_match_all('#\[img(?::\w+)?\]([\w:;&,~%+!=@\/\.\-\#\?]+)\[/img(?::\w+)?\]#si', $body, $img_tags, PREG_SET_ORDER)) {
    foreach ($img_tags as $img_tag) {
	$img_size = getimagesize($img_tag[1]);
		if ($img_size[0] > '570') {
		$body = str_replace($img_tag[0], '<img src="'. $img_tag[1] .'" width="570">', $body); }
		else {
		$body = str_replace($img_tag[0], '<img src="'. $img_tag[1] .'" >', $body); }
	}
}
RikiB’s picture

wow, this works great! This needs to be included! :)

RikiB’s picture

alas, I spoke too soon!

This caused a few bugs with my lightbox. Links were opening 2 of them or something and it forces alot of links thoughout the website to be lightbox when they shouldnt be. :/