Sorry, this page is only available in one language

Experimental Image Resizer script - WebsiteBaker

(Note: The droplet is also included in the download)

Unpack the zip on your local computer.
The script (image.php) must be placed in the /media/ directory.
It should have sufficient rights to create a cache directory for the cache to function. ( /media/cached_images/ )
The content of droplet.txt should be used to create your droplet.

Droplet code (v4)

//Scan page and replace all <img src=''> with a width or height set found in attributes of inline style information
//Should also work with images sized in CK-Editor

$wb_page_data str_replace('{ SYSVAR:MEDIA_REL }'$sMediaUrl$wb_page_data );

preg_match_all('/<img [^>]*>/im',$wb_page_data,$matches);
count($matches))return true// nothing found
foreach($matches[0] as $match){

preg_match('/width="[0-9]*"/i',$match) && preg_match('/height="[0-9]*"/i',$match)){
    } elseif(
preg_match('/style="[^"]*width: *[0-9]*px/i',$match) && preg_match('/style="[^"]*height: *[0-9]*px/i',$match)){
$width=preg_replace('/.*style="[^"]*width: *([0-9]*)px.*/i','\1',$match);
$height=preg_replace('/.*style="[^"]*height: *([0-9]*)px.*/i','\1',$match);
    } elseif(
preg_match('/style="[^"]*width: *[0-9]*px/i',$match)){
$width=preg_replace('/.*style="[^"]*width: *([0-9]*)px.*/i','\1',$match);
    } elseif(
preg_match('/style="[^"]*height: *[0-9]*px/i',$match)){
$height=preg_replace('/.*style="[^"]*height: *([0-9]*)px.*/i','\1',$match);
$width || !$height) continue;
$imgsrc preg_replace('/.*src="([^"]*)".*/i','\1',$match);
strpos($imgsrc,WB_URL.MEDIA_DIRECTORY) !== false ){ 
$src str_replace(WB_URL.MEDIA_DIRECTORY.'/',''$imgsrc);
file_exists(WB_PATH.MEDIA_DIRECTORY.'/'.urldecode($src))) continue;
$x || !$y || ($x==$width && $y==$height))continue;
$search[]  = 'src="'.$imgsrc.'"';
$width) {
$replace[] = 'src="'.WB_URL.'/media/images.php?i='.$src.'&w='.$width.'"';
        } else {
$replace[] = 'src="'.WB_URL.'/media/images.php?i='.$src.'&h='.$height.'"';
$search)) $wb_page_data str_replace($search,$replace,$wb_page_data);

Note: do not copy/paste the code above. It is modified a little bit to show the SYSVAR:MEDIA_REL in this page. Use the dropletcode in the download only!
Name the droplet something like "imgresizer" and include it on a page where you want the images to be resized.


Version 0.5.1
- fixes orientation (like vertical images from mobile phones)
- also handles webp images (creating jpg!)
- improved browser caching for resized images

* Droplet *
- dropletcode (v4) checks for existing files
License: GNU / GPL
Timestamp: 24-06-2020
Version: 0.5.1
Filesize: 2.61 KB
Downloads: 24
Version: 0.3, Timestamp: 24-08-2017, Downloads: 294
Version 0.3
Bugfix - Droplet now first rewrites { SYSVAR:MEDIA_REL }.
The file images.php is not changed.
Version: 0.2, Timestamp: 17-08-2012, Downloads: 1153
Version 0.2
Imageresizer code similar to v0.1 but an improved droplet.
Now also supports inline style width/height settings (for CK-Editor)
Version: 0.1, Timestamp: 04-06-2012, Downloads: 1333
Version 0.1
Note: this is an experiment. It is not advised (yet) to use this in production websites

Back to the parent page