Keyword

Image cache questions

More
14 years 3 months ago #72543 by FidoBoy
Replied by FidoBoy on topic Image cache questions
You are right, my mistake, file is item.php not items.php. I'm sorry...

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

More
14 years 3 months ago #72544 by Abderrahim
Replied by Abderrahim on topic Image cache questions
Hi, i have a similar question about images generation!
but, if I want just generate (S and XS) sizes only in cache without (XL,L,M,Generic), and without modifying in source code, where i can found this option in k2 =) ?

[Note:: i have setting "-1" in k2 control panel for (XL,L,...) but images has generated with size = 1x1 = ~1kb ]

thank!

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

More
14 years 1 month ago #72545 by Gerard Croteau
Replied by Gerard Croteau on topic Image cache questions
thank you

I add that peices of code
but I still have the same problem
the thumbnails in the blog author are all resized extra small ( ie. from original file of 100 X 100, they are all resized to 14 X 14)
I flushed the cache, I refreshed the menus, always the same problem
thumbnails are not of the size entered in the set up

any suggestions ?
thanks



Kristiyan Ivanchevski said:Thanks. Will try ASAP.
fidoboy said:Well, finally i've created a patch to allow image cache reconstruction from sources using current image size parameters. You must open the file items.php (into the models folder of frontpage component). Locate the function prepareItem and then into this function, locate the following lines:
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XS.jpg'))<br/>
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.jpg'))<br/>
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.jpg'))<br/>
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.jpg'))<br/>
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.jpg'))<br/>
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.jpg'))<br/>
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.jpg';<br/>

replace those lines with this code:
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XS.jpg'))
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.jpg';
else
$item-&gt;imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'xsmall');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.jpg'))
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.jpg';
else
$item-&gt;imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'small');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.jpg'))
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.jpg';
else
$item-&gt;imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'medium');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.jpg'))
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.jpg';
else
$item-&gt;imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'large');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.jpg'))
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.jpg';
else
$item-&gt;imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'xlarge');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.jpg'))
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.jpg';
else
$item-&gt;imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'generic');

and finally at the end of class K2ModelItem (just before the last } ) add this new function:
function rebuildImageFromSrc ($srcImage, $params, $newImgSize) {
if (!JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$srcImage.'.jpg')) return "";

require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'class.upload.php');
$handle = new Upload(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$srcImage.'.jpg');
$handle-&gt;allowed = array('image/*');

$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'jpg';
$handle-&gt;jpeg_quality = $params-&gt;get('imagesQuality');
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = false;

switch($newImgSize) {
case 'xlarge':
$handle-&gt;file_new_name_body = $srcImage.'_XL';
$imageWidth = $params-&gt;get('itemImageXL', '800');
$handle-&gt;image_x = $imageWidth;
break;
case 'large':
$handle-&gt;file_new_name_body = $srcImage.'_L';
$imageWidth = $params-&gt;get('itemImageL', '600');
$handle-&gt;image_x = $imageWidth;
break;
case 'medium':
$handle-&gt;file_new_name_body = $srcImage.'_M';
$imageWidth = $params-&gt;get('itemImageM', '400');
$handle-&gt;image_x = $imageWidth;
break;
case 'small':
$handle-&gt;file_new_name_body = $srcImage.'_S';
$imageWidth = $params-&gt;get('itemImageS', '200');
$handle-&gt;image_x = $imageWidth;
break;
case 'xsmall':
$handle-&gt;file_new_name_body = $srcImage.'_XS';
$imageWidth = $params-&gt;get('itemImageXS', '100');
$handle-&gt;image_x = $imageWidth;
break;
case 'generic':
$handle-&gt;file_new_name_body = $srcImage.'_Generic';
$imageWidth = $params-&gt;get('itemImageGeneric', '300');
$handle-&gt;image_x = $imageWidth;
break;
}
$handle-&gt;Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache');

return JURI::root().'media/k2/items/cache/'.$handle-&gt;file_dst_name_body.'.jpg';
}

That's all, i hope that you enjoy the new function!! Now if you delete some or all images from the cache folder, they are rebuilded from their sources (using the new size if it has changed). It works fine for me...

kind regards,

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

More
14 years 1 month ago #72546 by Gerard Croteau
Replied by Gerard Croteau on topic Image cache questions
something more :
I use CB as I doing a migration to J15 from J1015. CB was installed to the former site and I saw that K2 login can't manage the database of CB

do CB setup for avatar sizes bug K2 avatar sizes, even they are set up to be the same ?
thanks

Gerard Croteau said:thank you

I add that peices of code
but I still have the same problem
the thumbnails in the blog author are all resized extra small ( ie. from original file of 100 X 100, they are all resized to 14 X 14)
I flushed the cache, I refreshed the menus, always the same problem
thumbnails are not of the size entered in the set up

any suggestions ?
thanks



Kristiyan Ivanchevski said:Thanks. Will try ASAP. fidoboy said:Well, finally i've created a patch to allow image cache reconstruction from sources using current image size parameters. You must open the file items.php (into the models folder of frontpage component). Locate the function prepareItem and then into this function, locate the following lines:
<br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XS.jpg'))<br/>
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.jpg'))<br/>
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.jpg'))<br/>
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.jpg'))<br/>
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.jpg'))<br/>
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.jpg'))<br/>
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.jpg';<br/>

replace those lines with this code:
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XS.jpg'))
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.jpg';
else
$item-&gt;imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'xsmall');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.jpg'))
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.jpg';
else
$item-&gt;imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'small');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.jpg'))
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.jpg';
else
$item-&gt;imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'medium');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.jpg'))
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.jpg';
else
$item-&gt;imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'large');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.jpg'))
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.jpg';
else
$item-&gt;imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'xlarge');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.jpg'))
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.jpg';
else
$item-&gt;imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'generic');

and finally at the end of class K2ModelItem (just before the last } ) add this new function:
function rebuildImageFromSrc ($srcImage, $params, $newImgSize) {
if (!JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$srcImage.'.jpg')) return "";

require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'class.upload.php');
$handle = new Upload(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$srcImage.'.jpg');
$handle-&gt;allowed = array('image/*');

$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'jpg';
$handle-&gt;jpeg_quality = $params-&gt;get('imagesQuality');
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = false;

switch($newImgSize) {
case 'xlarge':
$handle-&gt;file_new_name_body = $srcImage.'_XL';
$imageWidth = $params-&gt;get('itemImageXL', '800');
$handle-&gt;image_x = $imageWidth;
break;
case 'large':
$handle-&gt;file_new_name_body = $srcImage.'_L';
$imageWidth = $params-&gt;get('itemImageL', '600');
$handle-&gt;image_x = $imageWidth;
break;
case 'medium':
$handle-&gt;file_new_name_body = $srcImage.'_M';
$imageWidth = $params-&gt;get('itemImageM', '400');
$handle-&gt;image_x = $imageWidth;
break;
case 'small':
$handle-&gt;file_new_name_body = $srcImage.'_S';
$imageWidth = $params-&gt;get('itemImageS', '200');
$handle-&gt;image_x = $imageWidth;
break;
case 'xsmall':
$handle-&gt;file_new_name_body = $srcImage.'_XS';
$imageWidth = $params-&gt;get('itemImageXS', '100');
$handle-&gt;image_x = $imageWidth;
break;
case 'generic':
$handle-&gt;file_new_name_body = $srcImage.'_Generic';
$imageWidth = $params-&gt;get('itemImageGeneric', '300');
$handle-&gt;image_x = $imageWidth;
break;
}
$handle-&gt;Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache');

return JURI::root().'media/k2/items/cache/'.$handle-&gt;file_dst_name_body.'.jpg';
}

That's all, i hope that you enjoy the new function!! Now if you delete some or all images from the cache folder, they are rebuilded from their sources (using the new size if it has changed). It works fine for me...

kind regards,

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

More
13 years 9 months ago #72547 by BBC
Replied by BBC on topic Image cache questions
Did you change item.php in administrator/components? Or just /components/com_k2.
Because I don´t get it to work. How is cache rebuild? By frontpage refresh? Or save in K2 admin panel`?

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

More
13 years 9 months ago #72548 by BBC
Replied by BBC on topic Image cache questions
OK, it works. Browser cache delay. But can´t get it to work with new dimensions (height hack).

href="community.getk2.org/forum/topics/creat-thumbnail-by-width-and?id=3536014%3ATopic%3A20874&page=4#comments

They are restored with old width settings, height hack is ignored. If i make new item hack is respected.

Thanks for solution.

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

More
13 years 8 months ago #72549 by dvlancer
Replied by dvlancer on topic Image cache questions
Just what I was looking for!

fidoboy said:Well, finally i've created a patch to allow image cache reconstruction from sources using current image size parameters. You must open the file items.php (into the models folder of frontpage component). Locate the function prepareItem and then into this function, locate the following lines:
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XS.jpg'))<br/>
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.jpg'))<br/>
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.jpg'))<br/>
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.jpg'))<br/>
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.jpg'))<br/>
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.jpg';<br/>
<br/>
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.jpg'))<br/>
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.jpg';<br/>

replace those lines with this code:
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XS.jpg'))
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.jpg';
else
$item-&gt;imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'xsmall');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.jpg'))
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.jpg';
else
$item-&gt;imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'small');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.jpg'))
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.jpg';
else
$item-&gt;imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'medium');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.jpg'))
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.jpg';
else
$item-&gt;imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'large');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.jpg'))
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.jpg';
else
$item-&gt;imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'xlarge');

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.jpg'))
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.jpg';
else
$item-&gt;imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item-&gt;id), $item-&gt;params, 'generic');

and finally at the end of class K2ModelItem (just before the last } ) add this new function:
function rebuildImageFromSrc ($srcImage, $params, $newImgSize) {
if (!JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$srcImage.'.jpg')) return "";

require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'class.upload.php');
$handle = new Upload(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.$srcImage.'.jpg');
$handle-&gt;allowed = array('image/*');

$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'jpg';
$handle-&gt;jpeg_quality = $params-&gt;get('imagesQuality');
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = false;

switch($newImgSize) {
case 'xlarge':
$handle-&gt;file_new_name_body = $srcImage.'_XL';
$imageWidth = $params-&gt;get('itemImageXL', '800');
$handle-&gt;image_x = $imageWidth;
break;
case 'large':
$handle-&gt;file_new_name_body = $srcImage.'_L';
$imageWidth = $params-&gt;get('itemImageL', '600');
$handle-&gt;image_x = $imageWidth;
break;
case 'medium':
$handle-&gt;file_new_name_body = $srcImage.'_M';
$imageWidth = $params-&gt;get('itemImageM', '400');
$handle-&gt;image_x = $imageWidth;
break;
case 'small':
$handle-&gt;file_new_name_body = $srcImage.'_S';
$imageWidth = $params-&gt;get('itemImageS', '200');
$handle-&gt;image_x = $imageWidth;
break;
case 'xsmall':
$handle-&gt;file_new_name_body = $srcImage.'_XS';
$imageWidth = $params-&gt;get('itemImageXS', '100');
$handle-&gt;image_x = $imageWidth;
break;
case 'generic':
$handle-&gt;file_new_name_body = $srcImage.'_Generic';
$imageWidth = $params-&gt;get('itemImageGeneric', '300');
$handle-&gt;image_x = $imageWidth;
break;
}
$handle-&gt;Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache');

return JURI::root().'media/k2/items/cache/'.$handle-&gt;file_dst_name_body.'.jpg';
}

That's all, i hope that you enjoy the new function!! Now if you delete some or all images from the cache folder, they are rebuilded from their sources (using the new size if it has changed). It works fine for me...

kind regards,

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

More
13 years 6 months ago #72550 by Adamo
Replied by Adamo on topic Image cache questions
Excuse me for the trivial question but, if there is a necessity and if there is also a solution why this solution is not implemented in the main project?

I ask this because i have the same problem and i also know how to use the hack here proposed but i don't like hack the core because at avery update i have to check if i have to re-hack the code.

Would not it be easier if the improvement is implemented in the K2 component? How can we propose improvements?

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

  • Alfonso F. Moreno
  • Alfonso F. Moreno's Avatar
  • Offline
  • Elite Member
More
13 years 6 months ago #72551 by Alfonso F. Moreno
Replied by Alfonso F. Moreno on topic Image cache questions
I'm with youAdrabi its very exensive in space to resize all the images in 6 different sizes what means six images per article. I think there is no option to avoid rezizing from all sizes. Maybe the only way its to delete from cache if you are not going to use it once made the resizing or, as you say, let the other sizes 1x1pixels.


Adrabi Abderrahim said:Hi, i have a similar question about images generation! but, if I want just generate (S and XS) sizes only in cache without (XL,L,M,Generic), and without modifying in source code, where i can found this option in k2 =) ?

[Note:: i have setting "-1" in k2 control panel for (XL,L,...) but images has generated with size = 1x1 = ~1kb ]

thank!

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

More
13 years 5 months ago #72552 by HJM Cortooms
Replied by HJM Cortooms on topic Image cache questions
Wouldn't it be nice if someone uploaded the hacked item.php file for version 2.4.1?

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


Powered by Kunena Forum