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.