From: Alan Jack Pippin Date: Sun, 1 Jul 2007 06:35:06 +0000 (-0600) Subject: Initial stab at getting the thumbnail resize feature working. X-Git-Tag: 1_0_4~4 X-Git-Url: http://git.pippins.net/embedvideo/.git/static/images/%7Beqpres_ppi_link%7D?a=commitdiff_plain;h=2266d371cd774ad41e57be7520b3121486437615;p=embedvideo%2F.git Initial stab at getting the thumbnail resize feature working. --- diff --git a/ItemAddEmbedVideo.inc b/ItemAddEmbedVideo.inc index 28d4a80..6d1e8d7 100644 --- a/ItemAddEmbedVideo.inc +++ b/ItemAddEmbedVideo.inc @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +GalleryCoreApi::requireOnce('modules/gd/classes/GdToolkitHelper.class'); + + /** * This plugin will handle the addition of embedded video objects * @package embedVideo @@ -517,8 +520,36 @@ class ItemAddEmbedVideo extends ItemAddPlugin { print "

Video Successfully Added to your Gallery Album

"; } + /* Resize the thumbnail image to the size indicated by our album */ + list ($ret, $toolkit) = GalleryCoreApi::getToolkitByOperation($mimeType, 'resize'); + if (!$ret) { + if(!strcmp($debugOutput,"true")) { + print "Checking to see if toolkit was found
"; + } + if (isset($toolkit)) { + $newTmpFile = $platform->tempnam($tmpDir, 'add'); + $newTmpFile.= ".jpg"; + $thumbnailSize = 150; + list ($ret, $preferences) = GalleryCoreApi::fetchDerivativePreferencesForItem($item->getId()); + if(!$ret) { + foreach ($preferences as $preference) { + if (preg_match('/thumbnail\|(\d+)/', + $preference['derivativeOperations'], $matches)) { + $thumbnailSize = $matches[1]; + break; + } + } + } + if(!strcmp($debugOutput,"true")) { + print "Resizing thumbnail image to $thumbnailSize: $tmpFile -> $newTmpFile
"; + } + $toolkit->performOperation($mimeType, 'resize', $tmpFile, $newTmpFile, + array($thumbnailSize,$thumbnailSize)); + } + } + /* Make the gallery2 call to add this item to the album */ - list ($ret, $newItem) = GalleryCoreApi::addItemToAlbum($tmpFile, + list ($ret, $newItem) = GalleryCoreApi::addItemToAlbum($newTmpFile, $fileName, $title, $summary, @@ -534,7 +565,13 @@ class ItemAddEmbedVideo extends ItemAddPlugin { 'id' => $newItem->getId(), 'warnings' => array()); } - @$platform->unlink($tmpFile); + + /* Keep the tmpfiles around if we are in debug mode. Otherwise, remove them. */ + if(!strcmp($debugOutput,"false")) { + @$platform->unlink($tmpFile); + @$platform->unlink($newTmpFile); + } + } return array(null, $error, $status); diff --git a/module.inc b/module.inc index eb03f50..9ca5ffb 100644 --- a/module.inc +++ b/module.inc @@ -33,7 +33,7 @@ class EmbedVideoModule extends GalleryModule { $this->setId('embedvideo'); $this->setName($gallery->i18n('Embed Video')); $this->setDescription($gallery->i18n('Add embedded videos from the web')); - $this->setVersion('1.0.1'); + $this->setVersion('1.0.2'); $this->setGroup('import', $gallery->i18n('Import')); $this->setCallbacks('getSiteAdminViews'); $this->setRequiredCoreApi(array(7, 4));