public function __construct($slideshow_web_path, $thumbnail_sizes = false, $alias = false) { $this->slideshow_web_path = $slideshow_web_path; if (!$alias) { $this->alias = substr($slideshow_web_path, strrpos($slideshow_web_path, '/', -2) + 1); } else { $this->alias = $alias; } // Now call the thumbnail generator parent::__construct($slideshow_web_path, $thumbnail_sizes); }
} if (is_file($educationpath)) { unlink($educationpath); } $tmp_name = $_FILES['form_education']['tmp_name']; if (!move_uploaded_file($tmp_name, $educationpath)) { die(text(xl('Unable to create') . " '{$educationpath}'")); } } } /** * Thumbnails generator * generating thumbnail image to all images files from documents table */ if (isset($_POST['generate_thumbnails'])) { $thumb_generator = new ThumbnailGenerator(); $results = $thumb_generator->generate_all(); $thumbnail_msg = "<p style='color: green'>" . xlt('Generated thumbnail(s)') . " : " . text($results['sum_success']) . "</p>"; $thumbnail_msg .= "<p style='color: red'>" . xlt('Failed to generate') . " : " . text($results['sum_failed']) . "</p>"; foreach ($results['failed'] as $key => $file) { $num = $key + 1; $thumbnail_msg .= "<p style='color: red; font-size: 11px'> " . text($num) . ". " . text($file) . "</p>"; } } else { $count_not_generated = ThumbnailGenerator::count_not_generated(); $thumbnail_msg = "<p>" . xlt('Files with empty thumbnail') . ": " . text($count_not_generated) . " </p>"; } ?> <html> <head>
/** * Download images from their remote paths, convert them to thumbnails and save them * @param $urls */ protected static function cacheAndConvertImagesByUrls($urls) { foreach ($urls as $url) { try { $sourceFileName = basename($url); $targetFileName = static::generateTargetFileName($sourceFileName); $sourceFilePath = static::getSourceFilePathByName($sourceFileName); $targetFilePath = static::getThumbFilePathByName($targetFileName); // pull image from remote into local path for caching purposes static::cacheImage($url, $sourceFilePath); // got the image? time to create thumbnail for it. ThumbnailGenerator::generate($sourceFilePath, $targetFilePath, static::THUMB_WIDTH, static::THUMB_HEIGHT); // successfully generated thumbnail? add it to the items we have processed. static::$thumbnails[] = $targetFilePath; } catch (Exception $e) { // couldn't process the item for some reason? Say remote resource is not available? // add it to failed items so we know we need to fix these. static::$failedToLoad[] = $url; } } }