WebsiteBaker 2.13.9 R24 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
<tr> <td colspan="2"> <input type="checkbox" name="watermark" id="watermark" value="yes" checked /> <label for="watermark"> Voeg watermerk toe aan {TEXT_FILES} </label> </td></tr><tr> <td colspan="2"> <input type="radio" name="imgscale" value="width" checked /> Gebruik maximum breedte (460px) bij {TEXT_FILES}<br /> <input type="radio" name="imgscale" value="height" /> Gebruik maximum hoogte (350px) bij {TEXT_FILES}<br /> <input type="radio" name="imgscale" value="none" /> Geen verandering aan grootte <br /> </td></tr>
// Find out whether we should add a watermark or notif($admin->get_post('watermark') != '') { $watermark = true;} else { $watermark = false;}// Find out whether we should resize the imageif($admin->get_post('imgscale') != '') { $imgscale = $admin->get_post('imgscale');} else { $imgscale = "none";}......//lots of code and then in upload loop//resize image if(file_exists($relative.$filename) AND strcasecmp ($imgscale, "width") == 0) { $resized = img_width($relative.$filename, 460); $source = fopen($relative.$filename, 'wb'); fwrite($source, $resized); fclose($source); } elseif(file_exists($relative.$filename) AND strcasecmp ($imgscale, "height") == 0) { $resized = img_height($relative.$filename, 350); $source = fopen($relative.$filename, 'wb'); fwrite($source, $resized); fclose($source); } //add watermark if(file_exists($relative.$filename) AND $watermark == true) { $watermarked = add_watermark($relative.$filename, "./watermark.png"); $source = fopen($relative.$filename, 'wb'); fwrite($source, $watermarked); fclose($source); }
include 'api.watermark.php';...function add_watermark($filename, $watermarkfilename){ $watermark = new watermark(); # create image objects using our user-specified images # NOTE: we're just going to assume we're dealing with a JPG and a PNG here - for example purposes $main_img_obj = imagecreatefromjpeg($filename); $watermark_img_obj = imagecreatefrompng($watermarkfilename); # create our watermarked image - set 22% alpha transparency for our watermark $return_img_obj = $watermark->create_watermark( $main_img_obj, $watermark_img_obj, 22 ); # display our watermarked image - first telling the browser that it's a JPEG, # and that it should be displayed inline //header( 'Content-Type: image/jpeg' ); //header( 'Content-Disposition: inline; filename=' . $_GET['src'] ); ob_start(); imagejpeg( $return_img_obj, '', 80 ); $buffer = ob_get_contents(); ob_end_clean(); return $buffer;}function img_width($filename, $prefwidth){ $srcimage = imagecreatefromjpeg($filename); $width = imageSX($srcimage); $height = imageSY($srcimage); if($width > $prefwidth) { $newWidth = $prefwidth; $newscale = $height / $width; $newHeight = $newscale * $newWidth; } else { $newWidth = $width; $newHeight = $height; } $destimage = imagecreatetruecolor($newWidth, $newHeight); imagecopyresampled($destimage,$srcimage,0,0,0,0,$newWidth,$newHeight,$width,$height); ob_start(); ImageJPEG($destimage, '', 99); $return_img_obj = ob_get_contents(); ob_end_clean(); return $return_img_obj;}function img_height($filename, $prefheight){ $srcimage = imagecreatefromjpeg($filename); $width = imageSX($srcimage); $height = imageSY($srcimage); if($height > $prefheight) { $newHeight = $prefheight; $newscale = $width / $height; $newWidth = $newscale * $newHeight; } else { $newWidth = $width; $newHeight = $height; } $destimage = imagecreatetruecolor($newWidth, $newHeight); imagecopyresampled($destimage,$srcimage,0,0,0,0,$newWidth,$newHeight,$width,$height); ob_start(); ImageJPEG($destimage, '', 99); $return_img_obj = ob_get_contents(); ob_end_clean(); return $return_img_obj;}
Thanks Klaus,Aquila obviously didn't use the random image function. The solution in the thread you're referring at seems a little awkward to me, since you'd have to have an image for every single page you make - which is a lot of images when you're site is growing. Moreover, it doesn't seem very end-user-friendly.In my case I modified the templates, which does work, and gives the client the possibility to attach a special template to special pages. Maybe a better solution will come around - or maybe Aguila has it... Vincent