Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing createThumbs filename formatting #15

Merged
merged 1 commit into from
Dec 13, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
<legend>Gallery</legend>
<ul class="adminformlist" id="sortable">
<?php foreach($this->getGallery() as $photo) {
$img = 'com_gazebos/gallery/products/' . JRequest::getInt('product_id') . '/' . $photo->path;
$img = EEImageHelper::getThumbPath($img, '150x150');
$img = '/media/com_gazebos/gallery/products/' . JRequest::getInt('product_id') . '/thumbs/150x150_' . $photo->path;
if (is_file(JPATH_SITE . $img))
{
echo '
Expand Down
7 changes: 6 additions & 1 deletion libraries/easel/image/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ abstract class EEImageHelper
)
);

/**
* Filename format to save the generated thumbnails as.
*/
protected static $thumbFilenameFormat = '{width}x{height}_{filename}';

/**
* Create a JImage resource
*
Expand Down Expand Up @@ -112,7 +117,7 @@ public static function resizeImage($full_dir, $name, $info)

foreach (self::getThumbSizes() as $method => $sizes)
{
self::getInstance($full_dir.$name)->createThumbs($sizes, $method);
self::getInstance($full_dir.$name)->createThumbs($sizes, $method, null, self::$thumbFilenameFormat);
}
}

Expand Down
13 changes: 9 additions & 4 deletions libraries/joomla/image/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,13 @@ public function generateThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE
* Method to create thumbnails from the current image and save them to disk. It allows creation by resizing
* or croppping the original image.
*
* @param mixed $thumbSizes string or array of strings. Example: $thumbSizes = array('150x75','250x150');
* @param mixed $thumbSizes String or array of strings. Example: $thumbSizes = array('150x75','250x150');
* @param integer $creationMethod 1-3 resize $scaleMethod | 4 create croppping
* @param string $thumbsFolder destination thumbs folder. null generates a thumbs folder in the image folder
* @param string $thumbsFolder Destination thumbs folder. null generates a thumbs folder in the image folder
* @param string $format Filename format for the thumbnails to be saved to. Exclude extension from the format.
* {filename} - This will hold the files original name.
* {width} - This will hold the thumbnail width.
* {height} - This will hold the thumbnail height.
*
* @return array
*
Expand All @@ -278,7 +282,7 @@ public function generateThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE
*
* @since 12.2
*/
public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null)
public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null, $format = '{filename}_{width}x{height}')
{
// Make sure the resource handle is valid.
if (!$this->isLoaded())
Expand Down Expand Up @@ -315,7 +319,8 @@ public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE,
// Generate thumb name
$filename = pathinfo($this->getPath(), PATHINFO_FILENAME);
$fileExtension = pathinfo($this->getPath(), PATHINFO_EXTENSION);
$thumbFileName = $filename . '_' . $thumbWidth . 'x' . $thumbHeight . '.' . $fileExtension;
$tmpName = str_replace(array('{filename}', '{width}', '{height}'), array($filename, $thumbWidth, $thumbHeight), $format);
$thumbFileName = $tmpName . '.' . $fileExtension;

// Save thumb file to disk
$thumbFileName = $thumbsFolder . '/' . $thumbFileName;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 2 additions & 6 deletions templates/gazebos/html/com_gazebos/product/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
defined('_JEXEC') or die;

//Load admin language file
$lang = JFactory::getLanguage();
$lang->load('com_gazebos', JPATH_ADMINISTRATOR);

$spec_img_path = '/templates/gazebos/images/dummy-gazebo2.jpg';
JFactory::getLanguage()->load('com_gazebos', JPATH_ADMINISTRATOR);
?>

<div id="panels">
<ul id="tabs">
<li><a href="#photos">Gazebo Photos</a></li>
Expand Down Expand Up @@ -60,7 +56,7 @@

<div id="specs" class="panel">

<?php echo EEImageHelper::getThumb('com_gazebos/gallery/products/' . $this->item->id . '/' . $this->item->gallery[0]->path, '296x242'); ?>
<img src="<?php echo '/media/com_gazebos/gallery/products/' . $this->item->id . '/296x242_' . $this->item->gallery[0]->path; ?>" />
<ul>
<?php
$total = count($this->item->specifications['title']);
Expand Down