* 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
print "<br><br><b>Video Successfully Added to your Gallery Album</b><br><br>";
}
+ /* 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 <br>";
+ }
+ 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 <br>";
+ }
+ $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,
'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);
$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));