COMMUNITY FORUM
Search Results (Searched for: change K2 item images path)
- jethrodesign
14 Oct 2010 05:29
How to Add Custom Switches to K2 Image Gallery (using SIG Pro plugin)? was created by jethrodesign
How to Add Custom Switches to K2 Image Gallery (using SIG Pro plugin)?
Category: English K2 Community
Hi, we're using SIG Pro in conjunction with K2 to provide pop-up galleries for individual event items. The K2 item interface allows us to upload a zip file with all images on the 'Image Gallery' tab for each event/item. This works fine, and the pop-up galleries use the item title (usually name of event) as the caption for all images.
But on occasion, we would prefer to use a 'labels.txt' file to include custom captions for each individual image instead of the default 'global' caption.
According to the SIG Pro documentation, there are custom switches that can be used to override the defaults on an individual basis: {gallery}folder_path:thumbs_width:thumbs_height:display_mode:caption_mode{/gallery}
So we 'should' be able to add a custom switch for certain galleries to use the labels.txt file for captions instead of general.
Unfortunately, the K2 Image Gallery tab only displays the {gallery}item#{/gallery} text that gets generated, but does NOT allow you to edit this to add the switches.
- Is it possible to be able to modify this behavior so you could add the switches to allow for custom captions when necessary?
- If so, can you point me to which file(s) would have to change?
- Is there a simpler way to pull this off? Remember, we like the current behavior and only want to override it on occasion.
THANKS!
But on occasion, we would prefer to use a 'labels.txt' file to include custom captions for each individual image instead of the default 'global' caption.
According to the SIG Pro documentation, there are custom switches that can be used to override the defaults on an individual basis: {gallery}folder_path:thumbs_width:thumbs_height:display_mode:caption_mode{/gallery}
So we 'should' be able to add a custom switch for certain galleries to use the labels.txt file for captions instead of general.
Unfortunately, the K2 Image Gallery tab only displays the {gallery}item#{/gallery} text that gets generated, but does NOT allow you to edit this to add the switches.
- Is it possible to be able to modify this behavior so you could add the switches to allow for custom captions when necessary?
- If so, can you point me to which file(s) would have to change?
- Is there a simpler way to pull this off? Remember, we like the current behavior and only want to override it on occasion.
THANKS!
- Jakub Jedynak
05 Oct 2010 20:44
Replied by Jakub Jedynak on topic Reduce the size of image-k2 folder
Reduce the size of image-k2 folder
Category: English K2 Community
How to add extra disabled size option in K2 Options menu (lines numbers for v 2.3).
I. File "administrator/components/com_k2/config.xml"
CHANGE (line 12):
<param menu="hide" name="imagesQuality" type="text" default="100" size="4" label="Quality (%) used when processing images" description="" />
TO:
<param menu="hide" name="imagesQuality" type="text" default="100" size="4" label="Quality (%) used when processing images" description="" />
<param menu="hide" name="@spacer" type="spacer" default="" label="" description="" />
<param menu="hide" name="xs_size" type="radio" default="1" label="Use XSmall Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="s_size" type="radio" default="1" label="Use Small Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="m_size" type="radio" default="1" label="Use Medium Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="l_size" type="radio" default="1" label="Use Large Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="xl_size" type="radio" default="1" label="Use XLarge Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="@spacer" type="spacer" default="" label="" description="" />
II. File ""administrator/components/com_k2/models/item.php"
CHANGE (from line 204)
//XLarge image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params->get('itemImageXL', '800');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Medium image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params->get('itemImageM', '400');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Small image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
TO:
if ($params->get('xl_size', '1')) {
//XLarge image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params->get('itemImageXL', '800');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('l_size', '1')) {
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('m_size', '1')) {
//Medium image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params->get('itemImageM', '400');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('s_size', '1')) {
//Small image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('xs_size', '1')) {
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
III. File "administrator/components/com_k2/models/items.php"
CHANGE (from line 410)
//Source images
$sourceImage = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.md5("Image".$item->id).'.jpg';
$sourceImageXS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg';
$sourceImageS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg';
$sourceImageM = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg';
$sourceImageL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg';
$sourceImageXL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg';
TO:
//Source images
$sourceImage = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.md5("Image".$item->id).'.jpg';
if ($params->get('xs_size', '1')) {$sourceImageXS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg';}
if ($params->get('s_size', '1')) {$sourceImageS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg';}
if ($params->get('m_size', '1')) {$sourceImageM = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg';}
if ($params->get('l_size', '1')) {$sourceImageL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg';}
if ($params->get('xl_size', '1')) {$sourceImageXL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg';}
IV. File "administrator/language/en-GB/en-GB.com_k2.ini"
ADD (at the end of file)
/* use illustrations */
USE XSMALL IMAGES=Use X-Small Images
USE SMALL IMAGES=Use Small Images
USE MEDIUM IMAGES=Use Medium Images
USE LARGE IMAGES=Use Large Images
USE XLARGE IMAGES=Use X-Large Images
I. File "administrator/components/com_k2/config.xml"
CHANGE (line 12):
<param menu="hide" name="imagesQuality" type="text" default="100" size="4" label="Quality (%) used when processing images" description="" />
TO:
<param menu="hide" name="imagesQuality" type="text" default="100" size="4" label="Quality (%) used when processing images" description="" />
<param menu="hide" name="@spacer" type="spacer" default="" label="" description="" />
<param menu="hide" name="xs_size" type="radio" default="1" label="Use XSmall Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="s_size" type="radio" default="1" label="Use Small Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="m_size" type="radio" default="1" label="Use Medium Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="l_size" type="radio" default="1" label="Use Large Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="xl_size" type="radio" default="1" label="Use XLarge Images" description="">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param menu="hide" name="@spacer" type="spacer" default="" label="" description="" />
II. File ""administrator/components/com_k2/models/item.php"
CHANGE (from line 204)
//XLarge image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params->get('itemImageXL', '800');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Medium image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params->get('itemImageM', '400');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Small image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
TO:
if ($params->get('xl_size', '1')) {
//XLarge image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params->get('itemImageXL', '800');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('l_size', '1')) {
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('m_size', '1')) {
//Medium image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params->get('itemImageM', '400');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('s_size', '1')) {
//Small image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
if ($params->get('xs_size', '1')) {
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
}
III. File "administrator/components/com_k2/models/items.php"
CHANGE (from line 410)
//Source images
$sourceImage = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.md5("Image".$item->id).'.jpg';
$sourceImageXS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg';
$sourceImageS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg';
$sourceImageM = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg';
$sourceImageL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg';
$sourceImageXL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg';
TO:
//Source images
$sourceImage = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'src'.DS.md5("Image".$item->id).'.jpg';
if ($params->get('xs_size', '1')) {$sourceImageXS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg';}
if ($params->get('s_size', '1')) {$sourceImageS = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg';}
if ($params->get('m_size', '1')) {$sourceImageM = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg';}
if ($params->get('l_size', '1')) {$sourceImageL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg';}
if ($params->get('xl_size', '1')) {$sourceImageXL = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg';}
IV. File "administrator/language/en-GB/en-GB.com_k2.ini"
ADD (at the end of file)
/* use illustrations */
USE XSMALL IMAGES=Use X-Small Images
USE SMALL IMAGES=Use Small Images
USE MEDIUM IMAGES=Use Medium Images
USE LARGE IMAGES=Use Large Images
USE XLARGE IMAGES=Use X-Large Images
- Wire Creative
28 Sep 2010 02:14
BUG: Problems with Attachments was created by Wire Creative
BUG: Problems with Attachments
Category: English K2 Community
I've never been able to get Attachments to work, and on several sites I've simply chosen to ignore that feature entirely, but it would be a big help if I can get it to work on my current site. I'm using K2 ver. 2.4.My problem is, I think, that I override the default joomla and k2 paths for uploaded files. I have a directory off the root called "files" with child directories "images" "docs" "videos" etc.I have set the path overrides in the Joomla configuration & my JCE configuration and they both work fine.In k2's parameters I first set the "Change root attachments folder" to "files" hoping to get the attachments to go right into that directory off the root.After uploading an attachment, I was able to access the new file by clicking the "Download" button in the Item > Attachments tab, but if I tried to use the link displaying in the frontend, I would get a "file doesn't exist" error.Eventually I discovered that my new files were being errantly uploaded to this path:"administrator/files"So I changed the "Change root attachments folder" property to "/files" but now I can't access the "uploaded" attachment from either the frontend or backend and can't figure out where the attached file ended up being saved.Can anyone please help me figure out where to edit the file paths?Thanks,Greg
- Stephen Austin
24 Sep 2010 21:47
Replied by Stephen Austin on topic Undesired Feature?? - Transparent PNG's convert to jpg and loose transparency
Undesired Feature?? - Transparent PNG's convert to jpg and loose transparency
Category: English K2 Community
I've got a solution for this. its not super sexy, but it works.
in /components/com_k2/models/item.php replace the if chain starting on line 110 with:
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.png'))
$item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg'))
$item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.png'))
$item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))
$item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.png'))
$item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))
$item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.png'))
$item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))
$item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.png'))
$item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))
$item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.png'))
$item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))
$item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
In /administrator/components/com_k2/models/item.php insert this after the Generic image processing section line ~295:
/////////////////////PNG
//Original image
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src';
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = md5("Image".$row->id);
$handle->Process($savepath);
$filename = $handle->file_dst_name_body;
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache';
//XLarge image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params->get('itemImageXL', '800');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Medium image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params->get('itemImageM', '400');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Small image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Generic image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_Generic';
$imageWidth = $params->get('itemImageGeneric', '300');
$handle->image_x = $imageWidth;
$handle->Process($savepath);
Finally, wherever you are using an image from the k2 item, replace the .jpg extension with .png (if you need transparancy).
In short, technique writes an additional set of png (alpha intact) to the cache directory, and makes them available to the application via the same name as the jpg counterpart. No existing functionality should be broken by this since it is an additive change. I'll post a more thorough blog about this at some point.
One final note, if you need to implement the png version, a simple string replace looks something like this:
I'm a c# guy, not really php, and being as lazy as I am, I'm not going to look up how to do a proper substring trim... just dont name your image blah.png.png.png....
Good Luck!
in /components/com_k2/models/item.php replace the if chain starting on line 110 with:
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.png'))
$item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg'))
$item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.png'))
$item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))
$item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.png'))
$item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))
$item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.png'))
$item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))
$item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.png'))
$item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))
$item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.png'))
$item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.png';
else if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))
$item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
In /administrator/components/com_k2/models/item.php insert this after the Generic image processing section line ~295:
/////////////////////PNG
//Original image
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'src';
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = md5("Image".$row->id);
$handle->Process($savepath);
$filename = $handle->file_dst_name_body;
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache';
//XLarge image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params->get('itemImageXL', '800');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Large image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params->get('itemImageL', '600');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Medium image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params->get('itemImageM', '400');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Small image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//XSmall image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params->get('itemImageXS', '100');
}
$handle->image_x = $imageWidth;
$handle->Process($savepath);
//Generic image
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_convert = 'png';
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_Generic';
$imageWidth = $params->get('itemImageGeneric', '300');
$handle->image_x = $imageWidth;
$handle->Process($savepath);
Finally, wherever you are using an image from the k2 item, replace the .jpg extension with .png (if you need transparancy).
In short, technique writes an additional set of png (alpha intact) to the cache directory, and makes them available to the application via the same name as the jpg counterpart. No existing functionality should be broken by this since it is an additive change. I'll post a more thorough blog about this at some point.
One final note, if you need to implement the png version, a simple string replace looks something like this:
I'm a c# guy, not really php, and being as lazy as I am, I'm not going to look up how to do a proper substring trim... just dont name your image blah.png.png.png....
Good Luck!
- dvlancer
04 Sep 2010 15:28
Replied by dvlancer on topic Image cache questions
Image cache questions
Category: English K2 Community
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:
replace those lines with this code:
and finally at the end of class K2ModelItem (just before the last } ) add this new function:
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,
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->id).'_XS.jpg'))<br/> $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))<br/> $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))<br/> $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))<br/> $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))<br/> $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))<br/> $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->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->id).'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg'; else $item->imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xsmall'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg'; else $item->imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'small'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg'; else $item->imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'medium'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg'; else $item->imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'large'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg'; else $item->imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xlarge'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg'; else $item->imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->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->allowed = array('image/*'); $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_convert = 'jpg'; $handle->jpeg_quality = $params->get('imagesQuality'); $handle->file_auto_rename = false; $handle->file_overwrite = false; switch($newImgSize) { case 'xlarge': $handle->file_new_name_body = $srcImage.'_XL'; $imageWidth = $params->get('itemImageXL', '800'); $handle->image_x = $imageWidth; break; case 'large': $handle->file_new_name_body = $srcImage.'_L'; $imageWidth = $params->get('itemImageL', '600'); $handle->image_x = $imageWidth; break; case 'medium': $handle->file_new_name_body = $srcImage.'_M'; $imageWidth = $params->get('itemImageM', '400'); $handle->image_x = $imageWidth; break; case 'small': $handle->file_new_name_body = $srcImage.'_S'; $imageWidth = $params->get('itemImageS', '200'); $handle->image_x = $imageWidth; break; case 'xsmall': $handle->file_new_name_body = $srcImage.'_XS'; $imageWidth = $params->get('itemImageXS', '100'); $handle->image_x = $imageWidth; break; case 'generic': $handle->file_new_name_body = $srcImage.'_Generic'; $imageWidth = $params->get('itemImageGeneric', '300'); $handle->image_x = $imageWidth; break; } $handle->Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'); return JURI::root().'media/k2/items/cache/'.$handle->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,
- jack sudan
12 Aug 2010 01:18
Replied by jack sudan on topic K2 Templating
K2 Templating
Category: English K2 Community
Thanks Williaqm I got everything working, except one little problem the social sharing images and rating stars are not showing up, i mean the images are not there, even though when i mouse over the area where rating is i can rate and item.
any suggestions.
thanks in advance
John
William White said:If you are just wanting to change the file change it, it will affect the entire site and all categories. If you are using overrides and templating it will only affect where you tell it to and it wont change th core files or be overwritten when you update k2. In this case it should be somewhere like
YourSiteRoot/templates/YourCurrentTemplate/html/com_ke/templates/Your override name
after copying it into that directory, you must rename it to YourTemplateName_style.css for css4k2 to pick it up for that special use only...in other words when you are setting up a category you can select the override and it will get the special css styling that goes with the override.
John SHeridan said:John SHeridan said:Thank you william, if i make changes will it take affect without having to touch php files? Thans in advance William White said:two popluar posts about this are at simon.getk2.org/component/k2/item/91-templating and community.getk2.org/notes/Templating_in_K2 The original file k2.css should be found in a directory something like this
/httpdocs(YOUR ROOT)/components/com_k2/css
John SHeridan said:Why can't I find a style.css in my k2 template folder? The path is com_k2/templates/default??? only .php files in there and I just installed k2 so where is it? I have looked in all the sub folders too. I have found a k2.css file in com_k2/css/k2.css, is that the file? I want to change the items and category background in my template, I believe I have to override k2.css but can't find simple instructions on how to do this. Can anyone help Thanks in advance :)
Troponin said:You dont have to know php for styling settings - you should know something about css. Edit yout style.css in yout k2 template folder. for example: If you want to change the background color for comments div, search "itemComments" and change the background to #000000 (black). If you wanna learn something about css visit this site : CSS
Helpfull Tool for Firefox
any suggestions.
thanks in advance
John
William White said:If you are just wanting to change the file change it, it will affect the entire site and all categories. If you are using overrides and templating it will only affect where you tell it to and it wont change th core files or be overwritten when you update k2. In this case it should be somewhere like
YourSiteRoot/templates/YourCurrentTemplate/html/com_ke/templates/Your override name
after copying it into that directory, you must rename it to YourTemplateName_style.css for css4k2 to pick it up for that special use only...in other words when you are setting up a category you can select the override and it will get the special css styling that goes with the override.
John SHeridan said:John SHeridan said:Thank you william, if i make changes will it take affect without having to touch php files? Thans in advance William White said:two popluar posts about this are at simon.getk2.org/component/k2/item/91-templating and community.getk2.org/notes/Templating_in_K2 The original file k2.css should be found in a directory something like this
/httpdocs(YOUR ROOT)/components/com_k2/css
John SHeridan said:Why can't I find a style.css in my k2 template folder? The path is com_k2/templates/default??? only .php files in there and I just installed k2 so where is it? I have looked in all the sub folders too. I have found a k2.css file in com_k2/css/k2.css, is that the file? I want to change the items and category background in my template, I believe I have to override k2.css but can't find simple instructions on how to do this. Can anyone help Thanks in advance :)
Troponin said:You dont have to know php for styling settings - you should know something about css. Edit yout style.css in yout k2 template folder. for example: If you want to change the background color for comments div, search "itemComments" and change the background to #000000 (black). If you wanna learn something about css visit this site : CSS
Helpfull Tool for Firefox
- Matt Kaufmann
02 Jul 2010 18:30
Replied by Matt Kaufmann on topic Image SEO
Image SEO
Category: English K2 Community
I'm looking for a similar solution. I'd like K2 to leave the image in the directory in which the original image exists and I'd like it to generate different sized files in the directory of the original image based on the original file name by appending a suffix to the file name (_XS.jpg, _S.jpg, _M.jpg, etc.). I'd like it to stop generating random file names.
It looks like the following lines of code designate the image path and generate file names through the use of md5. These lines in components/com_k2/models/item.php clued me in:
There are also similar entries in components/com_k2/models/itemlist.php but there may be other files which contain references to this directory.
It would be easy enough to change the path by finding all references to it in which K2 either creates the image files or calls the image files. However, this doesn't allow us to separate the files into subdirectories and it doesn't allow us to keep the original file names.
Anyone else care to share some insight?
It looks like the following lines of code designate the image path and generate file names through the use of md5. These lines in components/com_k2/models/item.php clued me in:
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
There are also similar entries in components/com_k2/models/itemlist.php but there may be other files which contain references to this directory.
It would be easy enough to change the path by finding all references to it in which K2 either creates the image files or calls the image files. However, this doesn't allow us to separate the files into subdirectories and it doesn't allow us to keep the original file names.
Anyone else care to share some insight?
- Yiota
02 Jun 2010 13:50
Replied by Yiota on topic SIGPRO doesn't work with K2 Extensions
SIGPRO doesn't work with K2 Extensions
Category: Simple Image Gallery PRO
Very very important:
Haven't you noticed that the K2 component is broken inside the items in the backend? You need to re-install the component.
Now the SIG (free) doesn't have to be enabled (I took the liberty to disable it), in fact doesn't have to be installed at all once you have SIG Pro. I changed the path inside SIG Pro to the right one, which is the default (images/stories). K2 doesn't use this path anyway. The path is if you want to use the tags {gallery}{/gallery}.
Haven't you noticed that the K2 component is broken inside the items in the backend? You need to re-install the component.
Now the SIG (free) doesn't have to be enabled (I took the liberty to disable it), in fact doesn't have to be installed at all once you have SIG Pro. I changed the path inside SIG Pro to the right one, which is the default (images/stories). K2 doesn't use this path anyway. The path is if you want to use the tags {gallery}{/gallery}.
- Stephen
12 Apr 2010 20:25
Replied by Stephen on topic I can not run "image gallery".
I can not run "image gallery".
Category: English K2 Community
Hi Siegfried,
I can not find the statements:
$ Savepath = JPATH_ROOT.DS. 'Media'. DS. 'K2'. DS. 'Galleries';
if (JFolder:: exists (JPATH_ROOT.DS. 'media'. DS. "k2." DS. "galleries." DS. $ current-> id)) (
JFolder:: delete (JPATH_ROOT.DS. 'Media'. DS. "K2." DS. "Galleries." DS. $ Current-> id);
in the file components/com_k2/models/item.php
line 394 and 424.
I have a installed version 2.2 (latest version)
Did you wrong perhaps?
Note : Bist Du Deutsch?
siegfried Stahl said:sharky said:My solution: Chave change ligne 686 administrator/components/com_k2/models/item.php if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sig.php')) {
by
if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsig.php')) {
and maybe you had to add this for the free extension:
go to file: components/com_k2/models/item.php line394:
replace:
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries';
with:
$savepath = JPATH_ROOT.DS.'images'.DS.'stories';
and line 424:
relpace:
if (JFolder::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id);
with:
if (JFolder::exists(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id);
I can not find the statements:
$ Savepath = JPATH_ROOT.DS. 'Media'. DS. 'K2'. DS. 'Galleries';
if (JFolder:: exists (JPATH_ROOT.DS. 'media'. DS. "k2." DS. "galleries." DS. $ current-> id)) (
JFolder:: delete (JPATH_ROOT.DS. 'Media'. DS. "K2." DS. "Galleries." DS. $ Current-> id);
in the file components/com_k2/models/item.php
line 394 and 424.
I have a installed version 2.2 (latest version)
Did you wrong perhaps?
Note : Bist Du Deutsch?
siegfried Stahl said:sharky said:My solution: Chave change ligne 686 administrator/components/com_k2/models/item.php if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sig.php')) {
by
if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsig.php')) {
and maybe you had to add this for the free extension:
go to file: components/com_k2/models/item.php line394:
replace:
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries';
with:
$savepath = JPATH_ROOT.DS.'images'.DS.'stories';
and line 424:
relpace:
if (JFolder::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id);
with:
if (JFolder::exists(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id);
- Gerard Croteau
07 Mar 2010 07:51
Replied by Gerard Croteau on topic Image cache questions
Image cache questions
Category: English K2 Community
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:
replace those lines with this code:
and finally at the end of class K2ModelItem (just before the last } ) add this new function:
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,
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->id).'_XS.jpg'))<br/> $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))<br/> $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))<br/> $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))<br/> $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))<br/> $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))<br/> $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->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->id).'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg'; else $item->imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xsmall'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg'; else $item->imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'small'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg'; else $item->imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'medium'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg'; else $item->imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'large'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg'; else $item->imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xlarge'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg'; else $item->imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->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->allowed = array('image/*'); $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_convert = 'jpg'; $handle->jpeg_quality = $params->get('imagesQuality'); $handle->file_auto_rename = false; $handle->file_overwrite = false; switch($newImgSize) { case 'xlarge': $handle->file_new_name_body = $srcImage.'_XL'; $imageWidth = $params->get('itemImageXL', '800'); $handle->image_x = $imageWidth; break; case 'large': $handle->file_new_name_body = $srcImage.'_L'; $imageWidth = $params->get('itemImageL', '600'); $handle->image_x = $imageWidth; break; case 'medium': $handle->file_new_name_body = $srcImage.'_M'; $imageWidth = $params->get('itemImageM', '400'); $handle->image_x = $imageWidth; break; case 'small': $handle->file_new_name_body = $srcImage.'_S'; $imageWidth = $params->get('itemImageS', '200'); $handle->image_x = $imageWidth; break; case 'xsmall': $handle->file_new_name_body = $srcImage.'_XS'; $imageWidth = $params->get('itemImageXS', '100'); $handle->image_x = $imageWidth; break; case 'generic': $handle->file_new_name_body = $srcImage.'_Generic'; $imageWidth = $params->get('itemImageGeneric', '300'); $handle->image_x = $imageWidth; break; } $handle->Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'); return JURI::root().'media/k2/items/cache/'.$handle->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,
- Gerard Croteau
07 Mar 2010 07:34
Replied by Gerard Croteau on topic Image cache questions
Image cache questions
Category: English K2 Community
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:
replace those lines with this code:
and finally at the end of class K2ModelItem (just before the last } ) add this new function:
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,
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->id).'_XS.jpg'))<br/> $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))<br/> $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))<br/> $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))<br/> $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))<br/> $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))<br/> $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->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->id).'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg'; else $item->imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xsmall'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg'; else $item->imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'small'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg'; else $item->imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'medium'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg'; else $item->imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'large'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg'; else $item->imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xlarge'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg'; else $item->imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->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->allowed = array('image/*'); $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_convert = 'jpg'; $handle->jpeg_quality = $params->get('imagesQuality'); $handle->file_auto_rename = false; $handle->file_overwrite = false; switch($newImgSize) { case 'xlarge': $handle->file_new_name_body = $srcImage.'_XL'; $imageWidth = $params->get('itemImageXL', '800'); $handle->image_x = $imageWidth; break; case 'large': $handle->file_new_name_body = $srcImage.'_L'; $imageWidth = $params->get('itemImageL', '600'); $handle->image_x = $imageWidth; break; case 'medium': $handle->file_new_name_body = $srcImage.'_M'; $imageWidth = $params->get('itemImageM', '400'); $handle->image_x = $imageWidth; break; case 'small': $handle->file_new_name_body = $srcImage.'_S'; $imageWidth = $params->get('itemImageS', '200'); $handle->image_x = $imageWidth; break; case 'xsmall': $handle->file_new_name_body = $srcImage.'_XS'; $imageWidth = $params->get('itemImageXS', '100'); $handle->image_x = $imageWidth; break; case 'generic': $handle->file_new_name_body = $srcImage.'_Generic'; $imageWidth = $params->get('itemImageGeneric', '300'); $handle->image_x = $imageWidth; break; } $handle->Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'); return JURI::root().'media/k2/items/cache/'.$handle->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,
- jacklib
25 Feb 2010 20:27
images for fontsize & social sharing gone was created by jacklib
images for fontsize & social sharing gone
Category: English K2 Community
Hi! I created templates for each categories I created and created the template overrides as per instruction but I cannot see the images/icons for the fontsize and social sharing anymore it seems to be looking at the wrong path. I also copied the image folder from com_k2 to mytemplate/com_k2/images but still, images are not showing up. Unless I change the patch in the css for each item to components/com_k2/images then it shows. But I don't want to do that, or is that the only way?Please help!Thanks!
- siegfried Stahl
20 Feb 2010 00:55
Replied by siegfried Stahl on topic I can not run "image gallery".
I can not run "image gallery".
Category: English K2 Community
sharky said:My solution: Chave change ligne 686 administrator/components/com_k2/models/item.php
if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sig.php')) {
by
if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsig.php')) {
and maybe you had to add this for the free extension:
go to file: components/com_k2/models/item.php line394:
replace:
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries';
with:
$savepath = JPATH_ROOT.DS.'images'.DS.'stories';
and line 424:
relpace:
if (JFolder::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id);
with:
if (JFolder::exists(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id);
if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sig.php')) {
by
if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsigpro.php') || JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jwsig.php')) {
and maybe you had to add this for the free extension:
go to file: components/com_k2/models/item.php line394:
replace:
$savepath = JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries';
with:
$savepath = JPATH_ROOT.DS.'images'.DS.'stories';
and line 424:
relpace:
if (JFolder::exists(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'media'.DS.'k2'.DS.'galleries'.DS.$current->id);
with:
if (JFolder::exists(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id)) {
JFolder::delete(JPATH_ROOT.DS.'images'.DS.'stories'.DS.$current->id);
- Sorcio
05 Feb 2010 12:23
Rewritten URL for the categories was created by Sorcio
Rewritten URL for the categories
Category: English K2 Community
Rewritten URL for the categoriesGood day. Create a menu for him nominated categories, but when the path to the cache object is constantly changing. Sample
incorrect link:
http://mysite/index.php/club/misc/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=64&Itemid=256
precisely this way club / misk I do not exist.
The
next time you click on the same menu, the path is changed to
http://mysite/index.php/mainstr/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=64&Itemid=256
appeared / mainstr
This entire page is white, not loaded images and the template is only displayed text.
If the cache is turned off, the way the categories are correct. With ways to articles is no problem. How to solve this problem?
incorrect link:
http://mysite/index.php/club/misc/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=64&Itemid=256
precisely this way club / misk I do not exist.
The
next time you click on the same menu, the path is changed to
http://mysite/index.php/mainstr/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=64&Itemid=256
appeared / mainstr
This entire page is white, not loaded images and the template is only displayed text.
If the cache is turned off, the way the categories are correct. With ways to articles is no problem. How to solve this problem?
- Geoffww
05 Feb 2010 06:45 - 05 Feb 2010 06:54
Your JW_SIG not working in K2 content? Read this. was created by Geoffww
Your JW_SIG not working in K2 content? Read this.
Category: Simple Image Gallery
I've noticed 2 major faults after installing JW Simple Image Gallery 1.2.1 into Joomla 1.5.15 which cause this extension to not work.
File Name Conflict.
The core files of K2 are expecting this plugin to have the file name jw_sig.php. However the plugin installs as jwsig.php. Therefore, even though Joomla says it is, K2 thinks it's not installed because it can't find jw_sig.php. Edit the following K2 files.
FILE
administrator\components\com_k2\models\item.php
CHANGE jw_sig TO jwsig
FILE
administrator\components\com_k2\views\info\tmpl\default.php
CHANGE jw_sig TO jwsig
FILE
administrator\components\com_k2\views\item\view.html.php
CHANGE jw_sig TO jwsig
FILE
components\com_k2\views\item\view.html.php
CHANGE jw_sig TO jwsig
Gallery root folder conflict:
When you try to upload a zip file for your gallery in a K2 item the upload actually worked but the gallery won't show up. The plugin is looking for the gallery images in images/stories however K2 is uploading them into media/k2/galleries. Simply edit two plugin files to reflect the media/k2/galleries path.
FILE
plugins\content\plugin_jw_sig\showthumbs.php
CHANGE images/stories/ TO media/k2/galleries/
FILE
plugins\content\jwsig.php
CHANGE images/stories/ TO media/k2/galleries/
NOTE:
Incidentally I've noticed some have posted that they have little white boxes for thumbnails. This means that your showthumb.php file has the correct path on line 15 but the jwsig.php file doesn't have the same correct path on line 50. Both have to be the same path.
- 1. File name conflict: jw_sig.php AND jwsig.php
- 2. Gallery root folder conflict: /media/k2/galleries/ AND /images/stories/
File Name Conflict.
The core files of K2 are expecting this plugin to have the file name jw_sig.php. However the plugin installs as jwsig.php. Therefore, even though Joomla says it is, K2 thinks it's not installed because it can't find jw_sig.php. Edit the following K2 files.
FILE
administrator\components\com_k2\models\item.php
Line 775 - JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'jw_sig.php')) {
CHANGE jw_sig TO jwsig
FILE
administrator\components\com_k2\views\info\tmpl\default.php
Line 210 - if (JFile::exists(JPATH_PLUGINS.DS.'content'.DS.'<jw_sig>.php'))
CHANGE jw_sig TO jwsig
FILE
administrator\components\com_k2\views\item\view.html.php
Line 141 - JPluginHelper::importPlugin ('content', '<jw_sig>');
CHANGE jw_sig TO jwsig
FILE
components\com_k2\views\item\view.html.php
Line 464 - JPluginHelper::importPlugin('content', '<jw_sig>');
CHANGE jw_sig TO jwsig
Gallery root folder conflict:
When you try to upload a zip file for your gallery in a K2 item the upload actually worked but the gallery won't show up. The plugin is looking for the gallery images in images/stories however K2 is uploading them into media/k2/galleries. Simply edit two plugin files to reflect the media/k2/galleries path.
FILE
plugins\content\plugin_jw_sig\showthumbs.php
Line 15 - $_image_ = '../../../images/stories/'.$_GET['img'];
CHANGE images/stories/ TO media/k2/galleries/
FILE
plugins\content\jwsig.php
Line 50 - $rootfolder = '/images/stories/';
CHANGE images/stories/ TO media/k2/galleries/
NOTE:
Incidentally I've noticed some have posted that they have little white boxes for thumbnails. This means that your showthumb.php file has the correct path on line 15 but the jwsig.php file doesn't have the same correct path on line 50. Both have to be the same path.
- Kristiyan Ivanchevski
04 Nov 2009 02:35
Replied by Kristiyan Ivanchevski on topic Image cache questions
Image cache questions
Category: English K2 Community
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:
replace those lines with this code:
and finally at the end of class K2ModelItem (just before the last } ) add this new function:
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,
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->id).'_XS.jpg'))<br/> $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))<br/> $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))<br/> $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))<br/> $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))<br/> $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';<br/> <br/> if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))<br/> $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->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->id).'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg'; else $item->imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xsmall'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg'; else $item->imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'small'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg'; else $item->imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'medium'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg'; else $item->imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'large'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg'; else $item->imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xlarge'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg'; else $item->imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->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->allowed = array('image/*'); $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_convert = 'jpg'; $handle->jpeg_quality = $params->get('imagesQuality'); $handle->file_auto_rename = false; $handle->file_overwrite = false; switch($newImgSize) { case 'xlarge': $handle->file_new_name_body = $srcImage.'_XL'; $imageWidth = $params->get('itemImageXL', '800'); $handle->image_x = $imageWidth; break; case 'large': $handle->file_new_name_body = $srcImage.'_L'; $imageWidth = $params->get('itemImageL', '600'); $handle->image_x = $imageWidth; break; case 'medium': $handle->file_new_name_body = $srcImage.'_M'; $imageWidth = $params->get('itemImageM', '400'); $handle->image_x = $imageWidth; break; case 'small': $handle->file_new_name_body = $srcImage.'_S'; $imageWidth = $params->get('itemImageS', '200'); $handle->image_x = $imageWidth; break; case 'xsmall': $handle->file_new_name_body = $srcImage.'_XS'; $imageWidth = $params->get('itemImageXS', '100'); $handle->image_x = $imageWidth; break; case 'generic': $handle->file_new_name_body = $srcImage.'_Generic'; $imageWidth = $params->get('itemImageGeneric', '300'); $handle->image_x = $imageWidth; break; } $handle->Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'); return JURI::root().'media/k2/items/cache/'.$handle->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,
- FidoBoy
04 Nov 2009 02:21
Replied by FidoBoy on topic Image cache questions
Image cache questions
Category: English K2 Community
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:
replace those lines with this code:
and finally at the end of class K2ModelItem (just before the last } ) add this new function:
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,
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
replace those lines with this code:
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg')) $item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg'; else $item->imageXSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xsmall'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg')) $item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg'; else $item->imageSmall = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'small'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg')) $item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg'; else $item->imageMedium = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'medium'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg')) $item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg'; else $item->imageLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'large'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg')) $item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg'; else $item->imageXLarge = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->params, 'xlarge'); if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg')) $item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg'; else $item->imageGeneric = K2ModelItem::rebuildImageFromSrc(md5("Image".$item->id), $item->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->allowed = array('image/*'); $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_convert = 'jpg'; $handle->jpeg_quality = $params->get('imagesQuality'); $handle->file_auto_rename = false; $handle->file_overwrite = false; switch($newImgSize) { case 'xlarge': $handle->file_new_name_body = $srcImage.'_XL'; $imageWidth = $params->get('itemImageXL', '800'); $handle->image_x = $imageWidth; break; case 'large': $handle->file_new_name_body = $srcImage.'_L'; $imageWidth = $params->get('itemImageL', '600'); $handle->image_x = $imageWidth; break; case 'medium': $handle->file_new_name_body = $srcImage.'_M'; $imageWidth = $params->get('itemImageM', '400'); $handle->image_x = $imageWidth; break; case 'small': $handle->file_new_name_body = $srcImage.'_S'; $imageWidth = $params->get('itemImageS', '200'); $handle->image_x = $imageWidth; break; case 'xsmall': $handle->file_new_name_body = $srcImage.'_XS'; $imageWidth = $params->get('itemImageXS', '100'); $handle->image_x = $imageWidth; break; case 'generic': $handle->file_new_name_body = $srcImage.'_Generic'; $imageWidth = $params->get('itemImageGeneric', '300'); $handle->image_x = $imageWidth; break; } $handle->Process(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'); return JURI::root().'media/k2/items/cache/'.$handle->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,
- nauman
24 Jun 2009 22:28
My Bugs was created by nauman
My Bugs
Category: English K2 Community
First : I get an error every time, when i submit an article from backend
Cannot redeclare class Services_JSON in
public_html/administrator/components/com_k2/lib/JSON.php on line 128
I got same error on site page also on administrator page, then as advised by some member here, i tried it
forum.joomlaworks.gr/index.php?topic=8520.0
In /public_html/components/com_k2/models/item.php change the line
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'JSON.php');
to:
if (!class_exists('Services_JSON')) require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'JSON.php');
Solved the problem for me, it seems something else is also using JSON.php.
But Problem is same, seems to b solved on front end, but same here onadmin panel.
No 2 : There is No image styling in home page/ Category View pages, all images are overlapped, and posts too
Just my 2 cents
Cannot redeclare class Services_JSON in
public_html/administrator/components/com_k2/lib/JSON.php on line 128
I got same error on site page also on administrator page, then as advised by some member here, i tried it
forum.joomlaworks.gr/index.php?topic=8520.0
In /public_html/components/com_k2/models/item.php change the line
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'JSON.php');
to:
if (!class_exists('Services_JSON')) require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'lib'.DS.'JSON.php');
Solved the problem for me, it seems something else is also using JSON.php.
But Problem is same, seems to b solved on front end, but same here onadmin panel.
No 2 : There is No image styling in home page/ Category View pages, all images are overlapped, and posts too
Just my 2 cents