public function renderThumb($path, $width = 280, $height = 150, $isThumb = true, $quality = 100) { if ($isThumb) { $path = str_replace(JURI::base(), '', $path); $imagSource = JPATH_SITE . '/' . $path; $imagSource = urldecode($imagSource); $tmp = explode('/', $imagSource); $imageName = md5($path . $width . $height) . '-' . $tmp[count($tmp) - 1]; $thumbPath = $this->_thumbnailPath . $imageName; if (file_exists($imagSource)) { if (!file_exists($thumbPath)) { //create thumb BTImageHelper::createImage($imagSource, $thumbPath, $width, $height, true, $quality); } return $this->_thumbnaiURL . $imageName; } else { if (!file_exists($thumbPath)) { // Try to load image from external source // Image loaded? if ($this->_CreateImageUsingCurl($path, $thumbPath, 30)) { BTImageHelper::createImage($thumbPath, $thumbPath, $width, $height, true, $quality); return $this->_thumbnaiURL . $imageName; } } else { return $this->_thumbnaiURL . $imageName; } } } //return path return $path; }
public function renderThumb($path, $width = 280, $height = 150, $isThumb = true) { if ($isThumb) { if (!$path) { $path = $this->_defaultThumb; } $path = str_replace(JURI::base(), '', $path); $imagSource = JPATH_SITE . '/' . $path; $imagSource = urldecode($imagSource); if (file_exists($imagSource)) { $tmp = explode("/", $path); $imageName = $width . "x" . $height . "-" . $tmp[count($tmp) - 1]; $thumbPath = $this->_thumbnailPath . $imageName; if (!file_exists($thumbPath)) { //create thumb BTImageHelper::createImage($imagSource, $thumbPath, $width, $height, true); } $path = $this->_thumbnaiURL . $imageName; } } //return path return $path; }
<?php /** * @version $Id: images.php 1 Aug 20, 2011 9:51:20 AM Thomas $ * @package BTShowcase * @copyright Copyright (C) 2011 Bow Themes. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access defined('_JEXEC') or die; $items = json_decode(base64_decode($params->get('gallery'))); if (count($items) == 0) { echo JText::_('MOD_BTSLIDESWHO_NOTICE_NO_IMAGES'); return; } $moduleID = $module->id; // Clean images that haven't used require_once JPATH_ROOT . '/modules/mod_btslideshow/helpers/files.php'; BTFilesHelper::cleanFiles($items, $moduleID); // Make thumbnail & slideshow images if haven't created or just change the size require_once JPATH_ROOT . '/modules/mod_btslideshow/helpers/images.php'; $dir = JPATH_ROOT . '/modules/mod_btslideshow/images/' . $moduleID; foreach ($items as $item) { BTImageHelper::createImage("{$dir}/original/{$item->file}", "{$dir}/slideshow/{$item->file}", $params->get('width'), $params->get('height'), true, $params->get('jpeg-compression')); BTImageHelper::createImage("{$dir}/original/{$item->file}", "{$dir}/thumbnail/{$item->file}", $params->get('thumb-width'), $params->get('thumb-height'), true, $params->get('jpeg-compression')); } require JModuleHelper::getLayoutPath('mod_btslideshow', $params->get('layout', 'default'));