/** * @param string $filename * @param int $width * @param int $height * @return null|string */ function resize($filename, $width, $height) { if (!is_file(DIR_IMAGE . $filename)) { return null; } $info = pathinfo($filename); $extension = $info['extension']; if ($extension == 'ico') { $new_image = $filename; } else { $old_image = $filename; $new_image = 'thumbnails/' . substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension; if (!is_file(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) { $path = ''; $directories = explode('/', dirname(str_replace('../', '', $new_image))); foreach ($directories as $directory) { $path = $path . '/' . $directory; if (!file_exists(DIR_IMAGE . $path)) { @mkdir(DIR_IMAGE . $path, 0777); chmod(DIR_IMAGE . $path, 0777); } } $image = new AImage(DIR_IMAGE . $old_image); $image->resizeAndSave(DIR_IMAGE . $new_image, $width, $height, array('quality' => $this->config->get('config_image_quality'))); unset($image); } } if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) { return HTTPS_IMAGE . $new_image; } else { return HTTP_IMAGE . $new_image; } }
public function resize($filename, $width = 0, $height = 0) { if (!is_file(DIR_IMAGE . $filename)) { return null; } $https = $this->request->server['HTTPS']; if ($https == 'on' || $https == '1') { $http_path = HTTPS_IMAGE; } else { $http_path = HTTP_IMAGE; } $info = pathinfo($filename); $extension = $info['extension']; $old_image = $filename; $new_image = 'thumbnails/' . substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension; if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) { $path = ''; $directories = explode('/', dirname(str_replace('../', '', $new_image))); foreach ($directories as $directory) { $path = $path . '/' . $directory; if (!file_exists(DIR_IMAGE . $path)) { @mkdir(DIR_IMAGE . $path, 0777); chmod(DIR_IMAGE . $path, 0777); } } $image = new AImage(DIR_IMAGE . $old_image); $image->resize($width, $height); $image->save(DIR_IMAGE . $new_image); unset($image); } return $http_path . $new_image; }
/** * @param $filename - relative file path * @param int $width - in pixels * @param int $height - in pixels * @param null $alias - alias filename for saving * @param string $mode - can be url or file. * @return null|string - string is URL or abs file path */ public function resize($filename, $width = 0, $height = 0, $alias = null, $mode = 'url') { if (!is_file(DIR_IMAGE . $filename) && !is_file(DIR_RESOURCE . 'image/' . $filename)) { return null; } $old_image_filepath = is_file(DIR_IMAGE . $filename) ? DIR_IMAGE . $filename : ''; $old_image_filepath = $old_image_filepath == '' && is_file(DIR_RESOURCE . 'image/' . $filename) ? DIR_RESOURCE . 'image/' . $filename : $old_image_filepath; $https = $this->request->server['HTTPS']; if ($https == 'on' || $https == '1') { $http_path = HTTPS_IMAGE; } else { $http_path = HTTP_IMAGE; } //when need to get abs path of result if ($mode == 'path') { $http_path = DIR_IMAGE; } $info = pathinfo($filename); $extension = $info['extension']; $alias = !$alias ? $filename : dirname($filename) . '/' . basename($alias); $new_image = 'thumbnails/' . substr($alias, 0, strrpos($alias, '.')) . '-' . $width . 'x' . $height . '.' . $extension; $new_image_filepath = DIR_IMAGE . $new_image; //retina variant $new_image2x = 'thumbnails/' . substr($alias, 0, strrpos($alias, '.')) . '-' . $width . 'x' . $height . '@2x.' . $extension; $new_image_filepath2x = DIR_IMAGE . $new_image2x; if (!file_exists($new_image_filepath) || filemtime($old_image_filepath) > filemtime($new_image_filepath) || !file_exists($new_image_filepath2x) || filemtime($old_image_filepath) > filemtime($new_image_filepath2x)) { $path = ''; $directories = explode('/', dirname(str_replace('../', '', $new_image))); foreach ($directories as $directory) { $path = $path . '/' . $directory; if (!file_exists(DIR_IMAGE . $path)) { @mkdir(DIR_IMAGE . $path, 0777); chmod(DIR_IMAGE . $path, 0777); } } $image = new AImage($old_image_filepath); $quality = $this->config->get('config_image_quality'); $image->resizeAndSave($new_image_filepath, $width, $height, array('quality' => $quality)); unset($image); if ($this->config->get('config_retina_enable')) { $image = new AImage($old_image_filepath); $image->resizeAndSave($new_image_filepath2x, $width * 2, $height * 2, array('quality' => $quality)); unset($image); } } if ($this->config->get('config_retina_enable') && isset($this->request->cookie['HTTP_IS_RETINA'])) { $new_image = $new_image2x; } return $http_path . $new_image; }
static function getListTour($params) { $xheight = $params->get('iheight', 200); $xwidth = $params->get('iwidth', 200); require_once JPATH_ROOT . '/administrator/components/com_bookpro/models/tours.php'; $source = $params->get('source', 'latest'); $model = new BookProModelTours(); $state = $model->getState(); $state->set('filter.days', $params->get('duration', null)); $state->set('filter.cat_id', $params->get('cat_id', null)); $state->set('filter.dest_id', $params->get('dest_id', null)); $state->set('filter.featured', $params->get('featured', null)); $state->set('list.limit', $params->get('count', null)); $state->set('list.start', 0); $state->set('filter.state', 1); $data = $model->getItems(); $config = JComponentHelper::getParams('com_bookpro'); $itemId = $params->get('Itemid'); foreach ($data as $i => $row) { $data[$i]->text = $data[$i]->description; $data[$i]->title = $row->title; $data[$i]->link = JRoute::_('index.php?option=com_bookpro&view=tour&id=' . $data[$i]->id . '&Itemid=' . $itemId); if ($data[$i]->img_path) { $thumb = AImage::thumb($data[$i]->img_path, $xwidth, $xheight); } else { $ipath = 'components/com_bookpro/assets/images/no_image.jpg'; $thumb = AImage::thumb($ipath, $xwidth, $xheight); } $data[$i]->image_html = '<img src="' . $thumb . '">'; } return $data; }
protected function getInput() { jimport('joomla.filesystem.folder'); $bar = JToolBar::getInstance('toolbar_image'); $bar->addButtonPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'toolbar'); /* @var $bar JToolBar */ $bar->appendButton('Popup', 'new1', 'Add', ARoute::view(VIEW_IMAGES, null, null, array('tmpl' => 'component', 'type' => '1')), 800, 600); $bar->appendButton('ALink', 'delete', 'Delete', 'javascript:AImages.removeMain()', 'imageMainRemove'); $html[] = $bar->render(); $thumb = AImage::thumb(BookProHelper::getIPath($this->image), null, ADMIN_SET_IMAGES_WIDTH); $html[] = '<img src="' . $thumb . '" alt="" id="imageMainSource" class="thumb' . $thumb ? '' : ' blind' . '" />'; if (!$thumb) { $html[] = ADocument::addDomreadyEvent('AImages.hideRemoveMain()'); } $html[] = '<input type="hidden" name="image" id="imageMainHidden" value="' . $this->escape($this->image) . '" />'; return implode("\n", $html); }
private function _check_create_thumb($filename, $resource_filename, $width, $height) { if (!file_exists(DIR_IMAGE . $filename) || filemtime($resource_filename) > filemtime(DIR_IMAGE . $filename)) { $path = ''; $directories = explode('/', dirname(str_replace('../', '', $filename))); foreach ($directories as $directory) { $path = $path . '/' . $directory; if (!file_exists(DIR_IMAGE . $path)) { @mkdir(DIR_IMAGE . $path, 0777); chmod(DIR_IMAGE . $path, 0777); } } $image = new AImage($resource_filename); $image->resize($width, $height); $image->save(DIR_IMAGE . $filename); unset($image); } }
?> <legend><?php echo $this->title; ?> </legend> <?php } ?> <div class="row-fluid"> <?php $i = 0; foreach ($this->destinations as $dest) { $link = JRoute::_('index.php?option=com_bookpro&view=tours&dest_id=' . $dest->id . '&Itemid=' . $this->tour_itemid); //$ipath = BookProHelper::getIPath($dest->image); $thumb = AImage::thumb($dest->image, $this->width, $this->height); $model = new BookProModelTours(); $state = $model->getState(); $state->set('list.start', 0); $state->set('list.limit', 0); $state->set('filter.state', 1); $state->set('filter.dest_id', $dest->id); $numberTours = count($model->getItems()); if ($i == 0) { echo '<div class="row-fluid">'; } ?> <div class="span<?php echo 12 / $this->products_per_row; ?> ">
/** * Upload image. * * @param string $dest target directory to upload * @param string $field request fieldname * @param stdClass $image property where sets ouptput with this format: * $image->tmp ... request template file name * $image->name ... uploaded image name * $image->apath ... absolute path to image * $image->rpath ... real path to image * @param string $error property to set error messages * @return boolean */ function upload($dest, $field, &$image, &$error) { $adir = $dest; $rdir = JURI::root() . str_replace(DS, '/', $dest); $rdir = str_replace('//', '/', $dest); if (!file_exists($adir)) { if (!@mkdir($adir, 0775, true)) { $mainframe = JFactory::getApplication(); /* @var $mainframe JApplication */ $mainframe->enqueueMessage(sprintf(JText::_('Unable create directory %s'), $adir), 'error'); return false; } } if (isset($_FILES[$field])) { $request =& $_FILES[$field]; $image = new stdClass(); $image->tmp = $request['tmp_name']; $image->name = $request['name']; if ($request['error'] == 0) { $zip = new JArchiveZip(); $data = JFile::read($image->tmp); $isZip = $zip->checkZipData($data); unset($data); if ($isZip) { $tmpDir = AImage::getTmpDir(); $zip->extract($image->tmp, $tmpDir); unset($zip); $files =& JFolder::files($tmpDir, '.', true, true); $count = count($files); for ($i = 0; $i < $count; $i++) { $image->tmp = $files[$i]; $image->name = JFile::getName($image->tmp); AImage::save($image, $adir, $rdir); } JFolder::delete($tmpDir); return true; } else { unset($zip); return AImage::save($image, $adir, $rdir); } } } return false; }
/** * Get relative path to directory with image. * * @param $image add * into path image name * @return string */ function getRIPath($image) { $params =& JComponentHelper::getParams(OPTION); /* @var $params JParameter */ $ripath = $params->getValue('images', 'images/bookpro'); $ripath = AImage::getRIPath($ripath) . $image; return $ripath; }
<?php AImporter::helper('tour'); ?> <div class="div2_overview_nav_tabs text-left"> <?php if ($displayData) { foreach ($displayData as $t => $data) { $thumb = AImage::thumb($data->image); $spanafter = 12; ?> <div class="itinerary-row"> <div class="row-fluid"> <?php if ($data->image) { $spanafter = 10; ?> <div class="span2"> <img src="<?php echo $data->image; ?> " alt="<?php echo $data->title; ?> " class="thumbnail" style="width:95%;"> </div > <?php } ?> <div class="span<?php echo $spanafter; ?>
public function getResourceThumb($resource_id, $width = '', $height = '', $language_id = '') { if (!$language_id) { $language_id = $this->config->get('storefront_language_id'); } $resource = $this->getResource($resource_id, $language_id); switch ($this->type) { case 'image': if (!$resource['default_icon']) { $resource['default_icon'] = 'no_image.jpg'; } break; default: if (!$resource['default_icon']) { $resource['default_icon'] = 'no_image.jpg'; } $this->load->model('tool/image'); $this->model_tool_image->resize($resource['default_icon'], $width, $height); return $this->model_tool_image->resize($resource['default_icon'], $width, $height); } if (!empty($resource['resource_code'])) { return $resource['resource_code']; } $old_image = DIR_RESOURCE . $this->type_dir . $resource['resource_path']; $info = pathinfo($old_image); $extension = $info['extension']; if ($extension != 'ico') { if (!is_file($old_image)) { $this->load->model('tool/image'); $this->model_tool_image->resize($resource['default_icon'], $width, $height); return $this->model_tool_image->resize($resource['default_icon'], $width, $height); } $name = preg_replace('/[^a-zA-Z0-9]/', '', $resource['name']); //Build thumbnails path similar to resource library path $new_image = 'thumbnails/' . dirname($resource['resource_path']) . '/' . $name . '-' . $resource['resource_id'] . '-' . $width . 'x' . $height . '.' . $extension; if (!file_exists(DIR_IMAGE . $new_image) || filemtime($old_image) > filemtime(DIR_IMAGE . $new_image)) { $path = ''; $directories = explode('/', dirname(str_replace('../', '', $new_image))); foreach ($directories as $directory) { $path = $path . '/' . $directory; if (!file_exists(DIR_IMAGE . $path)) { @mkdir(DIR_IMAGE . $path, 0777); chmod(DIR_IMAGE . $path, 0777); } } $image = new AImage($old_image); $image->resize($width, $height); $image->save(DIR_IMAGE . $new_image); unset($image); } if (HTTPS === true) { return HTTPS_IMAGE . $new_image; } else { return HTTP_IMAGE . $new_image; } } else { // returns ico-file as is return $this->buildResourceURL($resource['resource_path'], 'full'); } }
<?php /** * @package Bookpro * @author Ngo Van Quan * @link http://joombooking.com * @copyright Copyright (C) 2011 - 2012 Ngo Van Quan * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html * @version $Id$ **/ defined('_JEXEC') or die('Restricted access'); $configJ = JComponentHelper::getParams('com_bookpro'); $images = $displayData; $gall_with = $configJ->get('display_gallery_preview_subject_detail_width', 1600); $gall_height = $configJ->get('display_gallery_preview_subject_detail_height', 900); if (count($images) > 1) { ?> <div class="fotorama" data-nav="thumbs" data-width="100%" data-fit="cover" data-ratio="<?php echo $gall_with / $gall_height; ?> "> <?php for ($i = 0; $i < count($images); $i++) { $ipath = $images[$i]->path; $thumb = AImage::thumb($ipath, $gall_with, $gall_height); echo '<img src="' . $thumb . '">'; } ?> </div> <?php }