Is there a way to easily recreate all thumbnails?

More
13 years 1 month ago #19963 by torkil
If I want to change the image settings and for instance increase the size of the medium thumbnail, is there an easy way I can recreate all thumbnails for all existing images?

Or is the only way to reupload the images? Seems to me like image scaling is only done on upload.

If that is the case: It would be brilliant if the image thumbnails are created the first time they are requested. In that way you can just delete all thumbnails if you want them recreated in new sizes.

Torkil Sinkaberg Johnsen
Web developer, BEDRE reklame
blog.bedre.no

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #19968 by ggppdk
Yes if you delete all thumbnails from thumbnail folder, they will be recreated with proper size the next time they are used.

But better backup the folder and test , then trash the backuped folder

Maybe there should be an option to delete thubmnails or maybe check size on display of each image and recreate thumbnails if needed (although this would put stress on the server of category views)

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #19971 by torkil
Which version is needed for this to work? Because I just imported lots of data and images, placing all images in the /components/com_flexicontent/uploads folder, but no thumbnails are created in images/stories/flexicontent.

Instead I get these warnings:

Warning: getimagesize(/.../images/stories/flexicontent/l_pa230015.jpg) [function.getimagesize]: failed to open stream: No such file or directory
/(...)/plugins/flexicontent_fields/image.php on line 178

This is FLEXIcontent 1.5.4 (r558). Perhaps I just need to upgrade to one of the beta releases?

Torkil Sinkaberg Johnsen
Web developer, BEDRE reklame
blog.bedre.no

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #19972 by torkil
I guess this says it all:
Code:
class plgFlexicontent_fieldsImage extends JPlugin { /* other code here*/ function rebuildThumbs( $field ) { // @TODO implement }

Torkil Sinkaberg Johnsen
Web developer, BEDRE reklame
blog.bedre.no

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #19983 by ggppdk
Yes this is not implemented yet.

Also, if you are making a NEW site, or just started using FLEXIcontent on an existing site, then please use the v1.5.6beta2, it is stable, has a lot of bug fixes, and only a few new bugs (except for the new advanced search feature which is not 100% complete).

Get it here:
code.google.com/p/flexicontent/downloads/list


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #20144 by torkil
I fixed this now, but with some code duplication so it's not very clean, but it works. I am using 1.5.6 beta2 (r922).

My solution: On display of an item, if an imagefile does not exist, for instance l_imagename.jpg, m_imagename.jpg or s_imagename.jpg, they are all created based on the field settings.

To recreate all thumbs, just delete the contents of the thumbs folder.

The code is a hack, but okay:

In class plgFlexicontent_fieldsImage, line 234 contains this:
Code:
$path = JPath::clean(JPATH_SITE . DS . $field->parameters->get('dir') . DS . 'l_' . $value['originalname']);

After this line, I inserted the following block of code:
Code:
// Add scaled images if they do not exist if (!file_exists($path)) { $sizes = array('l','m','s'); foreach ($sizes as $size) { $imgpath = JPath::clean(JPATH_SITE . DS . $field->parameters->get('dir') . DS . $size . '_' . $value['originalname']); if (!file_exists($imgpath)) { // some parameters for phpthumb $ext = strtolower(JFile::getExt($value['originalname'])); $onlypath = JPath::clean(COM_FLEXICONTENT_FILEPATH.DS); $destpath = JPath::clean(JPATH_SITE . DS . $field->parameters->get('dir', 'images/stories/flexicontent') . DS); $prefix = $size . '_'; $w = $field->parameters->get('w_'.$size); $h = $field->parameters->get('h_'.$size); $crop = $field->parameters->get('method_'.$size); $quality = $field->parameters->get('quality'); $usewm = $field->parameters->get('use_watermark_'.$size); $wmfile = JPath::clean(JPATH_SITE . DS . $field->parameters->get('wm_'.$size)); $wmop = $field->parameters->get('wm_opacity'); $wmpos = $field->parameters->get('wm_position'); // create the folder if it doesnt exists if (!JFolder::exists($destpath)) { if (!JFolder::create($destpath)) { JError::raiseWarning(100, $field->label . ' : ' . JText::_('Error. Unable to create folders')); return; } } // because phpthumb is an external class we need to make the folder writable if (JPath::canChmod($destpath)) { JPath::setPermissions($destpath, '0644', '0755'); } // create the thumnails using phpthumb $filename $this->imagePhpThumb( $onlypath, $destpath, $prefix, $value['originalname'], $ext, $w, $h, $quality, $size, $crop, $usewm, $wmfile, $wmop, $wmpos ); // set the filename for posting $post['originalname'] = $filename; } }

My code assumes that the original file exists, but that should be easy to check.

The foreach-loop I pasted in here is an almost exact copy of the foreach-loop in the end of the uploadOriginalFile()-method in the same class. This means that I just created a little code duplication… This loop could easily have been extracted and used in a separate method to avoid this, but I couldn't be bothered :)

The recreateThumbs() method would be really easy to create from this though. Just delete all thumbs first, then run this function on all files.

Torkil Sinkaberg Johnsen
Web developer, BEDRE reklame
blog.bedre.no

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.729 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline