break; case 'width': $size = $width; $sr = 1; $sizedwidth = $size; $sizedheight = round($height / $width * $size); break; case 'height': $size = $height; $sr = 1; $sizedwidth = Round($width / $height * $size); $sizedheight = $size; break; } $args = array($size, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL); $imageurl = getImageProcessorURI($args, $albumname, $imagepart); $iW = round($sizedwidth * 0.9); $iH = round($sizedheight * 0.9); $iX = round($sizedwidth * 0.05); $iY = round($sizedheight * 0.05); if (isset($_REQUEST['crop'])) { XSRFdefender('crop'); $cw = $_REQUEST['w']; $ch = $_REQUEST['h']; $cx = $_REQUEST['x']; $cy = $_REQUEST['y']; $rw = $width / $sizedwidth; $rh = $height / $sizedheight; $cw = round($cw * $rw); $ch = round($ch * $rh); $cx = round($cx * $rw);
/** * * Returns an URI to the image: * * If the image is not cached, the uri will be to the image processor * If the image is cached then the uri will depend on the site option for * cache serving. If the site is set for open cache the uri will point to * the cached image. If the site is set for protected cache the uri will * point to the image processor (which will serve the image from the cache.) * NOTE: this latter implies added overhead for each and every image fetch! * * @param array $args * @param string $album the album name * @param string $image the image name * @param int $mitme mtime of the image * @return string */ function getImageURI($args, $album, $image, $mtime) { $cachefilename = getImageCacheFilename($album, $image, $args); if (OPEN_IMAGE_CACHE && file_exists(SERVERCACHE . $cachefilename) && (!$mtime || filemtime(SERVERCACHE . $cachefilename) >= $mtime)) { return WEBPATH . '/' . CACHEFOLDER . imgSrcURI($cachefilename); } else { return getImageProcessorURI($args, $album, $image); } }
function getIPSizedImage($size, $image) { $wmt = getWatermarkParam($image, WATERMARK_IMAGE); $args = getImageParameters(array($size, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $wmt), $image->album->name); return getImageProcessorURI($args, $image->album->name, $image->filename); }
/** * Prints the images and/or albums as thumbnails of the selected album * * @param $number int The number of images per page * * @return string */ function printImageslist($number) { global $_zp_gallery, $host; $args = array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); if (isset($_GET['album']) && !empty($_GET['album'])) { $album = urldecode(sanitize($_GET['album'])); $albumobj = newAlbum($album); echo "<h3>" . gettext("Album:") . " <em>" . html_encode($albumobj->getTitle()) . unpublishedZenphotoItemCheck($albumobj, false) . "</em> / " . gettext("Album folder:") . " <em>" . html_encode($albumobj->name) . "</em><br /><small>" . gettext("(Click on image to include)") . "</small></h3>"; $images_per_page = $number; if (isset($_GET['page'])) { $currentpage = sanitize_numeric($_GET['page']); } else { $currentpage = 1; } $imagecount = $albumobj->getNumImages(); $pagestotal = ceil($imagecount / $images_per_page); printTinyPageNav($pagestotal, $currentpage, 'images'); // album thumb display; $albumthumb = $albumobj->getAlbumThumbImage(); $albumthumbalbum = $albumthumb->getAlbum(); $albumdesc = $albumobj->getDesc(); $imagedesc = $albumthumb->getDesc(); $imgurl = getImageProcessorURI($args, $albumthumbalbum->name, $albumthumb->filename); $fullimage = pathurlencode(addslashes($albumthumb->getFullImage())); $imageType = getImageType($albumthumb); if ($imageType) { // Not a pure image $backgroundcss = 'albumthumb-image'; $imgurl = $albumthumb->getThumb(); $itemid = $albumthumb->getID(); } else { $backgroundcss = 'albumthumb-other'; $imgurl = getImageProcessorURI($args, $albumthumbalbum->name, $albumthumb->filename); $itemid = $albumthumb->getID(); } $imgsizeurl = $albumthumb->getCustomImage(85, NULL, NULL, 85, 85, NULL, NULL, TRUE); echo "<div class='thumb'>"; echo "<a href=\"javascript: ZenpageDialog.insert('" . $itemid . "','" . $imgurl . "','" . $albumobj->getThumb() . "','" . "','" . urlencode($albumthumb->filename) . "','" . js_encode($albumthumb->getTitle()) . "','" . js_encode($albumobj->getTitle()) . "','" . $fullimage . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'zenphoto','" . js_encode(getWatermarkParam($albumthumb, WATERMARK_THUMB)) . "','" . js_encode(getWatermarkParam($albumthumb, WATERMARK_IMAGE)) . "','" . $imageType . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($imagedesc)) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($albumdesc)) . "');\"" . " title='" . html_encode($albumthumb->getTitle()) . " (" . html_encode($albumthumb->filename) . ")'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img src='" . $imgsizeurl . "' class='" . $backgroundcss . "' /></a>\n"; echo "<a href='../../../../../.." . html_encode($albumthumb->getLink()) . "' title='Zoom' rel='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a> " . gettext('<em>Albumthumb</em>') . unpublishedZenphotoItemCheck($albumthumb, false); echo "</div>"; $images = $albumobj->getImages(); if ($albumobj->getNumImages() != 0) { for ($nr = 1; $nr <= $pagestotal; $nr++) { $startimage[$nr] = $nr * $images_per_page - $images_per_page; // get start image number $endimage[$nr] = $nr * $images_per_page - 1; // get end image number } $number = $startimage[$currentpage]; for ($nr = $number; $nr <= $images_per_page * $currentpage; $nr++) { if ($nr === $imagecount) { break; } if (is_array($images[$nr])) { $linkalbumobj = newAlbum($images[$nr]['folder']); $imageobj = newImage($linkalbumobj, $images[$nr]['filename']); } else { $linkalbumobj = $albumobj; $imageobj = newImage($albumobj, $images[$nr]); } $imagedesc = $imageobj->getDesc(); $albumdesc = $linkalbumobj->getDesc(); $fullimage = pathurlencode(addslashes($imageobj->getFullImage())); $imageType = getImageType($imageobj); $thumburl = $imageobj->getThumb(); $imgurl = $imageobj->getLink(false); //$sizedimage = $imageobj->getSizedImage(getOption('image_size')); switch ($imageType) { case '': // image photo $backgroundcss = 'thumb-image'; $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename); $sizedimage = $imageobj->getSizedImage(getOption('image_size')); $sizedimage = '<img src="' . $sizedimage . '" alt="' . $imageobj->getTitle() . '" class="zenpage_sizedimage" />'; $itemid = ''; break; case 'textobject': $sizedimage = $imageobj->getSizedImage(getOption('image_size')); $sizedimage = str_replace('class="textobject"', 'class="textobject zenpage_sizedimage"', $sizedimage); $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename); $backgroundcss = 'thumb-textobject'; $itemid = ''; break; case 'video': case 'audio': $sizedimage = $imageobj->getThumb(); $sizedimage = str_replace('class="flowplayer"', 'class="mediaplayer zenpage_sizedimage"', $sizedimage); $imgurl = getImageProcessorURI($args, $linkalbumobj->name, $imageobj->filename); $backgroundcss = 'thumb-multimedia'; $itemid = $imageobj->getID(); break; default: $sizedimage = $imageobj->getSizedImage(getOption('image_size')); $backgroundcss = 'thumb-default'; $itemid = ''; break; } $imgsizeurl = $imageobj->getCustomImage(85, NULL, NULL, 85, 85, NULL, NULL, TRUE); echo "<div class='thumb'>\n"; echo "<a href=\"javascript:ZenpageDialog.insert('" . $itemid . "','" . $imgurl . "','" . $thumburl . "','" . html_encode($sizedimage) . "','" . urlencode($imageobj->filename) . "','" . js_encode($imageobj->getTitle()) . "','" . js_encode($linkalbumobj->getTitle()) . "','" . $fullimage . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'zenphoto','" . js_encode(getWatermarkParam($imageobj, WATERMARK_THUMB)) . "','" . js_encode(getWatermarkParam($imageobj, WATERMARK_IMAGE)) . "','" . $imageType . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($imagedesc)) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . html_encode(addslashes($albumdesc)) . "');\"" . " title='" . html_encode($imageobj->getTitle()) . " (" . html_encode($imageobj->filename) . ")'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img src='" . $imgsizeurl . "' class='" . $backgroundcss . "' /></a>\n"; echo "<a href='../../../../../.." . html_encode($imageobj->getLink()) . "' title='Zoom' rel='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a> " . html_encode(shortentitle($imageobj->getTitle(), 8)) . unpublishedZenphotoItemCheck($imageobj, false); echo "</div>\n"; if ($nr === $endimage[$currentpage]) { break; } } // for end } else { echo "<p class='noimages'>" . gettext("<strong>Note:</strong> This album does not contain any images.") . "</p>"; } // if/else no image end } // if GET album end }
/** * Get a default-sized thumbnail of this image. * * @return string */ function getThumb($type = 'image') { $ts = getOption('thumb_size'); if (getOption('thumb_crop')) { list($custom, $sw, $sh, $cw, $ch, $cx, $cy) = $this->getThumbCropping($type); if ($custom) { return $this->getCustomImage(NULL, $sw, $sh, $cw, $ch, $cx, $cy, true); } } else { $sw = $sh = NULL; } $filename = $this->filename; $wmt = getWatermarkParam($this, WATERMARK_THUMB); $args = getImageParameters(array($ts, NULL, NULL, $sw, $sh, NULL, NULL, NULL, true, NULL, true, $wmt, NULL, NULL), $this->album->name); $cachefilename = getImageCacheFilename($alb = $this->album->name, $filename, $args); if (file_exists(SERVERCACHE . $cachefilename) && filemtime(SERVERCACHE . $cachefilename) > $this->filemtime) { return WEBPATH . '/' . CACHEFOLDER . pathurlencode(imgSrcURI($cachefilename)); } else { return getImageProcessorURI($args, $this->album->name, $this->filename); } }
/** * Get a custom sized version of this image based on the parameters. * * @param string $alt Alt text for the url * @param int $size size * @param int $width width * @param int $height height * @param int $cropw crop width * @param int $croph crop height * @param int $cropx crop x axis * @param int $cropy crop y axis * @param string $class Optional style class * @param string $id Optional style id * @param bool $thumbStandin set to true to treat as thumbnail * @param bool $effects ignored * @return string */ function getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, $thumbStandin = false, $effects = NULL) { if ($thumbStandin) { $wmt = getOption('Video_watermark'); if (empty($wmt)) { $wmt = getWatermarkParam($this, WATERMARK_THUMB); } } else { $wmt = NULL; } $args = getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, $wmt, NULL, $effects), $this->album->name); if ($thumbStandin & 1) { if ($this->objectsThumb == NULL) { $filename = makeSpecialImageName($this->getThumbImageFile()); if (!getOption('video_watermark_default_images')) { $args[11] = '!'; } return getImageProcessorURI($args, $this->album->name, $filename); } else { $filename = $this->objectsThumb; $cachefilename = getImageCacheFilename($alb = $this->album->name, $filename, getImageParameters(array($size, $width, $height, $cropw, $croph, $cropx, $cropy, NULL, $thumbStandin, NULL, $thumbStandin, NULL, NULL, NULL)), $this->album->name); if (file_exists(SERVERCACHE . $cachefilename) && filemtime(SERVERCACHE . $cachefilename) > $this->filemtime) { return WEBPATH . '/' . CACHEFOLDER . pathurlencode(imgSrcURI($cachefilename)); } else { return getImageProcessorURI($args, $this->album->name, $filename); } } } else { $filename = $this->filename; $cachefilename = getImageCacheFilename($this->album->name, $filename, $args); if (file_exists(SERVERCACHE . $cachefilename) && filemtime(SERVERCACHE . $cachefilename) > $this->filemtime) { return WEBPATH . '/' . CACHEFOLDER . pathurlencode(imgSrcURI($cachefilename)); } else { return getImageProcessorURI($args, $this->album->name, $filename); } } }
break; case 'width': $originalSize = $size = $width; $sr = 1; $sizedwidth = $size; $sizedheight = round($height / $width * $size); break; case 'height': $originalSize = $size = $height; $sr = 1; $sizedwidth = round($width / $height * $size); $sizedheight = $size; break; } $pasteobj = isset($_REQUEST['performcrop']) && $_REQUEST['performcrop'] == 'pasteobj'; $imageurl = getImageProcessorURI(array($size, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL), $albumname, $imagepart); $iW = round($sizedwidth * 0.9); $iH = round($sizedheight * 0.9); $iX = round($sizedwidth * 0.05); $iY = round($sizedheight * 0.05); if (isset($_REQUEST['crop'])) { XSRFdefender('crop'); $cw = $_REQUEST['w']; $ch = $_REQUEST['h']; $cx = $_REQUEST['x']; $cy = $_REQUEST['y']; $rw = $width / $sizedwidth; $rh = $height / $sizedheight; $cw = round($cw * $rw); $ch = round($ch * $rh); $cx = round($cx * $rw);