
Swizec wrote: 1. did not know that existed![]()
Swizec wrote: 2. that would be my image cacher, yet to be validated![]()
MOD Name: Post Image Max. Size
Author: Swizec
MOD Description: Admin can set the maximum size of images displayed in posts. Images bigger than that are shrunk and turned into a link to the normal sized version.
MOD Name: Limit Image Width
Author: Vic D'Elfant
MOD Description: This MOD will scale each image in a post so it does not exceed the maximum image width set by you. Smaller images will retain their original size. When clicking such a scaled down image it will open at its original size in a separate popup window.
The image dimensions will be cached in order to avoid unnecessary delays when loading a page and checking the image dimensions

markus_petrux wrote: However, this MOD is simpler. To cache the getimagesize() result, it could simply do the job at first_pass time to replace the [img] bbcode with the [thmbimg] (already used by this MOD), so it gets saved in the posts_text table at post time (as if the user had used the [thmbimg] bbcode) with the image width et all.
IMHO, it looks interesting...
Code: Select all
function image_parse ( $post, $uid ) {
global $board_config, $lang, $bbcode_tpl;
preg_match_all( "/\[(img:$uid|img=right:$uid|img=left:$uid)\](\S+)\[\/(img:$uid)\]/i", $post, $matches);
foreach ( $matches[2] as $k => $img ) {
if ( !$size = @getimagesize( $img ) ) break;
$w = $size[0]; $h = $size[1];
$size = makeimgsize ( $size[0], $size[1] );
$img_align = strtok($matches[1][$k],":");
switch($img_align)
{
case "img=right":
$align = $lang['RIGHT'];
break;
case "img=left":
case "img":
default:
$align = $lang['LEFT'];
break;
}
$first = $matches[1][$k];
$secnd = $matches[3][$k];
$find = "[" . $first . "]" . str_replace( '', '/', $img ) . "[/" . $secnd . "]";
if ( !empty( $size ) )
{
$replace = $bbcode_tpl['thmbimg'];
$seek = array( '{IMAGE}', '{WIDTH}', '{HEIGHT}', '{SIZE}', '{NOTICE}', '{ALIGN}' );
$with = array( $img, $width, $height, $size, $lang['postimg_clickme'], $align );
$replace = str_replace( $seek, $with, $replace );
$post = str_replace( $find, $replace, $post );
}
}
return $post;
}
Code: Select all
<!-- BEGIN thmbimg --><table cellspacing="5" cellpadding="3" border="0" align="{ALIGN}"><tr><td align="center"><a href="#" onclick="javascript: window.open( '{IMAGE}', 'imgpop', 'width={WIDTH},height={HEIGHT},status=no,toolbar=no,menubar=no' );"><img src="{IMAGE}" align="center" border="0" {SIZE}></a><br /><span class="gensmall"><i>{NOTICE}</i></span></td></tr></table><!-- END thmbimg -->