Joomla image thumbs creation: lets make some clarity

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
dansky
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Thu Jan 10, 2008 4:42 pm
Location: Italy
Contact:

Joomla image thumbs creation: lets make some clarity

Post by dansky » Thu Apr 11, 2019 11:24 am

One of the most wanted feature I missed in Joomla (comparing to WP) was the ability to generate custom size thumbnails for intro and full images. Today with a few rows of code in the template I discovered and able to generate thumbnails of an intro image in different sizes and crops using createThumbs() Joomla! core function.

But I have some doubts:

1: Why in the official APIs is it labeled as "deprecated?
https://api.joomla.org/cms-3/classes/Jo ... eateThumbs
Are there new methods to do it?

2: Why is there so little documentation and so many third party extensions if it's possible to use core framework to make thumbnails?

3: Any developer/coder can tell me how to manage jpg compression with createThumbs()?

Code: Select all

	// PATH
	$image = new JImage(JPATH_BASE."/".$images->image_intro);
	// SIZES ARRAY
	$sizes = array('300x300', '500x500', '800x800');
	
	// PATH THUMBNAIL
	$thumb_image_path = pathinfo($images->image_intro)['dirname']."/thumbs/".pathinfo($images->image_intro)['filename']."_".$sizes[0].".".pathinfo($images->image_intro)['extension'];
	
	// IF FILE DOES NOT EXIST...
	if (!JFile::exists(getcwd()."/".$thumb_image_path)) {
		// CREATE THE THUMBS
		$thumb_image = $image->createThumbs($sizes, JImage::CROP_RESIZE); 
		
	}


waarnemer
Joomla! Hero
Joomla! Hero
Posts: 2954
Joined: Sun May 04, 2008 12:37 pm

Re: Joomla image thumbs creation: lets make some clarity

Post by waarnemer » Fri Apr 12, 2019 6:40 pm

First. When using this, you upload images, rework them and save them in a thumbs folder. Using up space of your server.

I would address this in a more practical manner. How many images do you show in your article page blog style (meaning show intro images)?
If it is over a 50 a page, it becomes interesting to "thumb" the images. If not, consider this.

Always optimize your images to the largest size used in your website. If the largest "view" of an image is 600x400px. Optimize it to that size before uploading.
For any lesser size, use css scaling.
Q. Why? A. As it reduces the amount of requests. The image shown at 60x40 is the same as the 600x400. But already cached by your browser. Thus no request, no download anymore.

This reduces traffic to your server. Thus activity. Your server can serve more visitors.

Now when you use a huge lot of thumbs (over a 50) in a page, then it will become interesting to have thumbs to reduce page loading times. But a 600x400px image is between 50 and 200k depending on compression.

dansky
Joomla! Intern
Joomla! Intern
Posts: 74
Joined: Thu Jan 10, 2008 4:42 pm
Location: Italy
Contact:

Re: Joomla image thumbs creation: lets make some clarity

Post by dansky » Sat Apr 13, 2019 7:20 am

Thanks a lot, interesting. But you did not answer any of my Q.

waarnemer
Joomla! Hero
Joomla! Hero
Posts: 2954
Joined: Sun May 04, 2008 12:37 pm

Re: Joomla image thumbs creation: lets make some clarity

Post by waarnemer » Sat Apr 13, 2019 7:42 pm

.. it isn't an anwer.. it is something to consider...


Locked

Return to “Joomla! 3.x Coding”