From: Alan Jack Pippin Date: Fri, 19 Oct 2007 05:35:25 +0000 (-0600) Subject: Added new watermarkAlignment option and added full path or URL support to image. X-Git-Tag: 1_1_1~14 X-Git-Url: http://git.pippins.net/embedvideo/.git/static/%22%22.%24thumbnail.%22/%7Bnolink%7D?a=commitdiff_plain;h=5e1dae2697864b504a086c160a605cfc8a45b9fa;p=embedvideo%2F.git Added new watermarkAlignment option and added full path or URL support to image. --- diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc index 03a54e9..4e517ac 100644 --- a/ItemAddEmbedVideo.inc +++ b/ItemAddEmbedVideo.inc @@ -70,7 +70,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { global $debugOutput, $useInternalFlvPlayer, $youtubeDevId; global $width, $height, $externalFlvPlayer, $externalFlvPlayerVars; global $flvThumbnail, $useRemoteSize, $autoStart; - global $watermarkVideos, $watermarkImage; + global $watermarkVideos, $watermarkImage, $watermarkAlignment; /* Find out what value our parameters should have by looking to see if they * are defined in our overrides section or default section. If they are not @@ -89,6 +89,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { $autoStart = $this->getParameter($ItemAddEmbedVideo, 'autoStart', "false"); $watermarkImage = $this->getParameter($ItemAddEmbedVideo, 'watermarkImage', ""); $watermarkVideos = $this->getParameter($ItemAddEmbedVideo, 'watermarkVideos', "false"); + $watermarkAlignment = $this->getParameter($ItemAddEmbedVideo, 'watermarkAlignment', "center"); /* Print our stored/set Parameters */ if(!strcmp($debugOutput,"true")) { @@ -107,6 +108,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { print "autoStart=$autoStart
"; print "watermarkVideos=$watermarkVideos
"; print "watermarkImage=$watermarkImage
"; + print "watermarkAlignment=$watermarkAlignment
"; print "
"; } @@ -661,31 +663,41 @@ class ItemAddEmbedVideo extends ItemAddPlugin { } else { $watermarkImage = $gallery2_url.$gallery2_video_watermark; } - + /* Get the watermark Image Extension */ preg_match('/\.(...)$/', $watermarkImage, $matches); $watermarkExt=$matches[1]; /* * Check to make sure the URL to the watermark image file is valid - * (That the file exists at the URL given) + * (That the file exists at the URL given). Skip this part if it is a local path. */ - list ($successfullyCopied, $response, $headers) = - $this->fetchWebFileHeaders($watermarkImage, $extraHeaders); - if (!$successfullyCopied) { - return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__, - "Unable to find the watermark image at url: $watermarkImage - $response"),NULL,NULL); - } + if(!preg_match("/^\//", $watermarkImage)) { + list ($successfullyCopied, $response, $headers) = + $this->fetchWebFileHeaders($watermarkImage, $extraHeaders); + if (!$successfullyCopied) { + return array(GalleryCoreApi::error(ERROR_BAD_PATH,__FILE__,__LINE__, + "Unable to find the watermark image at url: $watermarkImage - $response"),NULL,NULL); + } - /* Download the watermark image to a local file */ - $tmpDir = $gallery->getConfig('data.gallery.tmp'); - $watermark = $platform->tempnam($tmpDir, 'wmk_img_'); - $watermark.= "." . $watermarkExt; - list ($successfullyCopied, $response, $headers) = - GalleryCoreApi::fetchWebFile($watermarkImage, $watermark, $extraHeaders); - if (!$successfullyCopied) { - return array(GalleryCoreApi::error(ERROR_STORAGE_FAILURE,__FILE__,__LINE__, - "Unable to copy watermark image from url: $watermarkImage - $response"),null,null); + /* Download the watermark image to a local file */ + $tmpDir = $gallery->getConfig('data.gallery.tmp'); + $watermark = $platform->tempnam($tmpDir, 'wmk_img_'); + $watermark.= "." . $watermarkExt; + list ($successfullyCopied, $response, $headers) = + GalleryCoreApi::fetchWebFile($watermarkImage, $watermark, $extraHeaders); + if (!$successfullyCopied) { + return array(GalleryCoreApi::error(ERROR_STORAGE_FAILURE,__FILE__,__LINE__, + "Unable to copy watermark image from url: $watermarkImage - $response"),null,null); + } + } else { + $tmpDir = $gallery->getConfig('data.gallery.tmp'); + $watermark = $platform->tempnam($tmpDir, 'wmk_img_'); + $watermark.= "." . $watermarkExt; + if(!$platform->copy($watermarkImage, $watermark)) { + return array(GalleryCoreApi::error(ERROR_STORAGE_FAILURE,__FILE__,__LINE__, + "Unable to copy watermark image from path: $watermarkImage"),null,null); + } } /* See if there is a toolkit installed that can perform a composite operation */ @@ -726,8 +738,9 @@ class ItemAddEmbedVideo extends ItemAddPlugin { /* This has to be done to satisfy the argument requirement for the toolkit operation */ $dataDir = $gallery->getConfig('data.gallery.base'); $dataDir=preg_replace("/\//","\\/",$dataDir); - preg_match("/$dataDir(.*)/", $watermark, $matches); - $watermark = $matches[1]; + if(preg_match("/$dataDir(.*)/", $watermark, $matches)) { + $watermark = $matches[1]; + } /* General debug output */ if(!strcmp($debugOutput,"true")) { @@ -747,7 +760,7 @@ class ItemAddEmbedVideo extends ItemAddPlugin { $mimeType, 'composite', $newTmpFile, $tmpFile, array($watermark, $watermarkMimeType, $watermarkWidth, $watermarkHeight, - 'bottom-left', 0, 0)); + $watermarkAlignment, 0, 0)); /* Check the return code of the composite operation */ if ($ret) { diff --git a/templates/EmbedVideoSiteAdmin.tpl b/templates/EmbedVideoSiteAdmin.tpl index 56410db..d25226a 100644 --- a/templates/EmbedVideoSiteAdmin.tpl +++ b/templates/EmbedVideoSiteAdmin.tpl @@ -148,8 +148,11 @@ watermarkVideostrue/false {g->text text="specify whether you want to apply a watermark to the video thumbnails when they are added."} - watermarkImageURL path - {g->text text="URL path to an alternate image to use as a watermark for all video thumbnails."} + watermarkImageURL or local path + {g->text text="URL or local path to an alternate image to use as a watermark for all video thumbnails."} + + watermarkAlignmentalignment + {g->text text="Specify the watermark alignment: top-left, top, top-right, left, center, right, bottom-left, bottom, bottom-right"}