Keyword

Advanced Search

Search Results (Searched for: change K2 item images path)

  • barryP
  • barryP's Avatar
08 Mar 2012 14:50
Upload Gallery was created by barryP

Upload Gallery

Category: Simple Image Gallery PRO

Using SIG Pro, I set the base path to /images/stories/mystuff - fine
BUT when I use K2->image gallery tab to upload ZIP file the images go to media/k2/galleries - not so good
How do I change this??

Also, since the upload automatically creates a new folder with the name of the K2 item id I will need to always use
{gallery}#k2itemid{/gallery} to show the gallery
Since I don't know the itemid until after I save the K2 item can I use a 'generic' tag for every K2 item

Example {gallery}%ID%{/gallery}
  • mardulia
  • mardulia's Avatar
02 Mar 2012 23:03
k2 images galleries and media manager was created by mardulia

k2 images galleries and media manager

Category: English K2 Community

I'm using SIG Pro to put image galleries into K2 items. All is working fine- but I would like to be able to set it up so that my clients can easily write captions. Which is to say that they could easily access the file that SIG Pro makes for captions and stores in the same dir as the image gallery.

K2 uploads the images into media/k2/galleries, and seems to override whatever path I write into the SIG Pro pluging params. K2's beautiful(!) media manager root dir is /images and can't access /media.

If I could either change the dir where K2 stores galleries to something in /images- or change the root dir of the media manager- maybe to site root- so the image gallery directories are accessible in the media manager, I think that would do the trick.

Can either of these be done? And which would be better?

Thanks so much!
  • troponin
  • troponin's Avatar
28 Oct 2011 15:52
What would YODA do ? was created by troponin

What would YODA do ?

Category: English K2 Community

After a couple of my questions beeing unanswered I try another way of Heading my Topic ;)

I think the question is for "advanced" User, maybe someone can Help me.

I am using Joomla 1.7.2 with Joomlart T3 Framework and K2 v 2.5.1 and I have a Problem with the mod_K2_user render Module Function.

As I tried to use it with K2 v. 2.5 I had an Issue with white modal and pop-up screen as I set the link to Item_Edit_K2_Link to Menu. The Problem with white page is still happening even after Update to 2.5.1 where Joomlaworks says they fixed it. But the Error Code has changed.

Issue in K2 2.5
  • Wesley
  • Wesley's Avatar
20 Oct 2011 20:46
Replied by Wesley on topic How to have rotating Item images?

How to have rotating Item images?

Category: English K2 Community

Is it possible to add a Joomla content plugin to the item.php page? What I did was install the Simple Picture Slideshow plugin:
extensions.joomla.org/extensions/photos-a-images/images-slideshow/6432

I changed the image root path to: /media/k2/galleries/

In my item.php page I inserted the plugin code:
{besps}<?php echo $this->item->id; ?>{/besps}

This pulls the respective item's ID correctly but the plugin in not rendered, such as if my K2 item is 92 it shows:
{besps}92{/besps}


Thank you,
Wesley
  • JoomlaWorks
  • JoomlaWorks's Avatar
19 Oct 2011 19:16
Replied by JoomlaWorks on topic Caching? Changed images dont' appear on browser

Caching? Changed images dont' appear on browser

Category: English K2 Community

You see the same image because the image file is still the same and the browser thinks it's still the same image. Of course this doesn't happen forever. It depends on the browser and could take up to a few minutes for it to recognize the changed image, through the image's headers sent...

Anyway, since this was a problem high-traffic sites dealt with, we added this new option in the K2 parameters (in v2.5.0), which attached the item modified date to the name of the image file, thus forcing the browser to fetch the changed image.

In the backend, open the K2 parameters, switch to the "Images" tab, set "Force 'item modified date' as URL timestamp on image paths" to "Yes". Save.

Now you won't see this issue again.
  • BBC
  • BBC's Avatar
07 Jul 2011 12:12

[SOLVED] 2.5.1. version - cannot change Popup engine

Category: Simple Image Gallery PRO

Something else. All thumbs in Admin side (Image Gallery tab) are now just text. Maybe it is intentional, but all images and link under them got in path "administrator".

http://localhost/www/administrator/index.php?option=com_k2&view=item&cid=232#sigProGalleria1a962de730
  • B_Dark
  • B_Dark's Avatar
28 Jun 2011 22:44
Replied by B_Dark on topic Image cache questions

Image cache questions

Category: English K2 Community

nice script but have low jpg quality why? i want 100% quality

ansi.alpha said:
if anyone still need another solution , you might try this.i made it to when i transferred my wordpress to joomla k2 "troublesome".1. make php file at the top of your joomla directory. "anything.php"2.copy and paste the code in it then check it in your browser and wait until it finish loading.3. when it finish loading, change the 2nd parameter of recreateImg function in the while loop with the k2 Width you variable you want.4.if you get error memory limit reach just refresh and it will continue from where it stop."it happens if your image has really high size"5.delete this php file when you are done creating all images you want.

NOTE: this doesn't create md5 names of images but it could with abit coding. and if your imagesdosn't have md5 names,your images wont work in your k2.&lt;?php/** * $XS,$S,$M,$L,$XL,$Generic are k2 widths of new recreateImgd images in px . "you can find them in k2 panel" * you will need them change 2nd parameter of recreateImg function in the while loop after it finish generating files successfully. * probably not the default size setting. * if you change it ,change switch statment numbers to match them. */$XS = 133;$S = 409;$M = 745;$L = 766;$XL = 1066;$Generic = 300;//path to src folder of your images$srcPath = "./media/k2/items/src/";function recreateImg($file, $k2Width){    global $srcPath;    $imgPath = $srcPath . $file;    $imgname = $file;    // if you change k2 widths variables ,    // you will need to change numbers of each case to match them.    switch ($k2Width) {        case 133:            $size = 'XS';            break;        case 409:            $size = 'S';            break;        case 745:            $size = 'M';            break;        case 766:            $size = 'L';            break;        case 1066:            $size = 'XL';            break;        case 300:            $size = 'Generic';            break;    }    // the new image name and path to save it    $save = "./media/k2/items/cache/" . $imgname . '_' . $size . '.jpg';    if (file_exists($save)) {        echo $imgname . '_' . $size . '.jpg' . ' :Image exisit! &lt;br/&gt;';    } else {        $pic = imagecreatefromjpeg($imgPath);        $width = imagesx($pic);        $height = imagesy($pic);        $ratio = $k2Width / $width;        $newHeight = $height * $ratio;        $new_image = imagecreatetruecolor($k2Width, $newHeight);        imagecopyresampled($new_image, $pic, 0, 0, 0, 0, $k2Width, $newHeight, $width, $height);        imagedestroy($pic);        imagejpeg($new_image, $save);        imagedestroy($new_image);    }} // end of function//calling the function while looping each file if its jpg image$folder = opendir($srcPath);while ($file = readdir($folder)) {    if (substr($file, -4) == ".jpg") { //you can do images generations 1 size at one time by changing 2nd parameter .        recreateImg($file, $XS);    }}closedir($folder);?&gt;
  • BBC
  • BBC's Avatar
10 Apr 2011 01:28

Changing the browse server to browse the K2 images folder

Category: English K2 Community

You can change it in Joomla Global Configuration ----&gt; Media Settings ----&gt; Path to Media Folder

But you change then for whole Joomla (editor too),i believe.

 

Try to do something with this hack, if Global Settnigs doesn´t suit you:

community.getk2.org/forum/topics/k2-item-edit-hack-to-show-just
  • carmiaca
  • carmiaca's Avatar
30 Mar 2011 19:53

K2 Item Edit hack to show just the user's folder when browsing

Category: English K2 Community

In the item editing window when you click Browse Server on the Image tab it takes you to the default images folder set in Global Configurations in Joomla! so you see all the folders on the server. I didn't want the user to be able to select another user's content, so after a good deal of sleuthing I came up with this hack:

Open the administrator/components/com_k2/views/item/tmpl/filebrowser.php

On about line 12, under the restricted access and within the PHP tags put this to grab the user id:

$user =&amp; JFactory::getUser();$userid=$user-&gt;id;

 

Then at around line 32, under if(count($this-&gt;folders)): and still within the php tags put:

  if($this-&gt;path==$this-&gt;parent){//root folder of the images path            $this-&gt;folders=array($userid);//reduce folder array to just the user's folder   }

What it does is see if you are at the root images path and, if so, the folder array is changed so it contains only the user's folder.
  • ljk
  • ljk's Avatar
23 Mar 2011 23:53 - 24 Mar 2011 01:41
Replied by ljk on topic Remote Preview Image

Remote Preview Image

Category: AllVideos

Hi,

I have found that the plugin is not using flv but flvremote even when the video is on your website. So, to get the preview image to display I have made the following changes to the plugin version 3.3.

Backup the two files below, before you make the changes so you can fall back to a working copy if anything goes wrong.

In /plugins/content/jw_allvideos.php:
Around line 162 you will find this code:
 $tagcontent = preg_replace("/{.+?}/", "", $match); $tagparams = explode('|',$tagcontent); $tagsource = trim(strip_tags($tagparams[0])); $final_vwidth = (@$tagparams[1]) ? $tagparams[1] : $vwidth; 

Change it to:
 $tagcontent = preg_replace("/{.+?}/", "", $match); $tagparams = explode('|',$tagcontent); $tagsource = trim(strip_tags($tagparams[0])); /* Hack to display the preview image for flvrremote type videos */ if ($plg_tag == 'flvremote') { // Need to get the filename, without the extension so we can make the image filename $imagefile = substr($tagsource, 0, strrpos($tagsource,'.')); } else { $imagefile = ''; } /* End hack */ $final_vwidth = (@$tagparams[1]) ? $tagparams[1] : $vwidth;

Find this code:
 // source elements $findAVparams = array( "{SOURCE}", "{SOURCEID}", "{FOLDER}", "{WIDTH}", "{HEIGHT}", "{AUTOPLAY}", "{TRANSPARENCY}", "{BACKGROUND}", "{BACKGROUNDQT}", "{CONTROLBAR}", "{SITEURL}", );

Replace it with this code:
 // source elements $findAVparams = array( "{SOURCE}", "{SOURCEID}", "{FOLDER}", "{WIDTH}", "{HEIGHT}", "{AUTOPLAY}", "{TRANSPARENCY}", "{BACKGROUND}", "{BACKGROUNDQT}", "{CONTROLBAR}", "{SITEURL}", "{IMAGEURL}", // Add image url to parameters list );

Find this code:
 // replacement elements if(in_array($plg_tag, array("mp3","mp3remote","wma","wmaremote"))){ $replaceAVparams = array( $tagsource, substr(md5($tagsource),1,8), $afolder, $awidth, $aheight, $final_autoplay, $transparency, $background, $backgroundQT, $controlBarLocation, $siteUrl, ); $output->playerWidth = $awidth; $output->playerHeight = $aheight; } else { $replaceAVparams = array( $tagsource, substr(md5($tagsource),1,8), $vfolder, $final_vwidth, $final_vheight, $final_autoplay, $transparency, $background, $backgroundQT, $controlBarLocation, $siteUrl, );

Replace it with this code:
 // replacement elements if(in_array($plg_tag, array("mp3","mp3remote","wma","wmaremote"))){ $replaceAVparams = array( $tagsource, substr(md5($tagsource),1,8), $afolder, $awidth, $aheight, $final_autoplay, $transparency, $background, $backgroundQT, $controlBarLocation, $siteUrl, $imagefile,  // Add image url to parameters list ); $output->playerWidth = $awidth; $output->playerHeight = $aheight; } else { $replaceAVparams = array( $tagsource, substr(md5($tagsource),1,8), $vfolder, $final_vwidth, $final_vheight, $final_autoplay, $transparency, $background, $backgroundQT, $controlBarLocation, $siteUrl, $imagefile,  // Add image url to parameters list );

Finally in /plugins/content/jw_allvideos/includes/sources.php on line 39 in the flvremote section replace:
 <param name=\"flashvars\" value=\"file={SOURCE}&autostart={AUTOPLAY}{CONTROLBAR}&fullscreen=true\" />

with:
 <param name=\"flashvars\" value=\"file={SOURCE}&image={IMAGEURL}.jpg&autostart={AUTOPLAY}{CONTROLBAR}&fullscreen=true\" />

Making these changes should now give you a preview images as long as you have the image in the same folder as your flv file and you name the image file the same as the flv file, but with a .jpg extension. If you wanted a different extension on your image file change it in the line above (.jpg for .png, if you wanted png images instead).

To get the image to display properly in K2 you need to add the following hack to remove the beginning / from the video path:

/administrator/components/com_k2/views/item/tmpl/fielbrowser.php line 42 remove the beginning / from the <a href="
                    <a href="/<?php echo $this->path.'/'.$file;?>" class="<?php echo $this->type;?>File">                         <img width="64" alt="<?php echo $file;?>" src="<?php echo ($this->type=='video')? JURI::root().'administrator/components/com_k2/images/system/video.png':JURI::root().$this->path.'/'.$file;?>">

becomes:
                    <a href="<?php echo $this->path.'/'.$file;?>" class="<?php echo $this->type;?>File">                         <img width="64" alt="<?php echo $file;?>" src="<?php echo ($this->type=='video')? JURI::root().'administrator/components/com_k2/images/system/video.png':JURI::root().$this->path.'/'.$file;?>">


I hope this helps others get their preview image for flv files.

Good luck.
  • Yiota
  • Yiota's Avatar
21 Mar 2011 18:52

Automatically add a picture when ignoring the "Choose a image" in the add an item form

Category: English K2 Community

To the category_item.php (override K2 template first, if not already), locate the catItemImageBlock.

 

&lt;?php if($this-&gt;item-&gt;params-&gt;get('catItemImage') &amp;&amp; !empty($this-&gt;item-&gt;image)): ?&gt;            &lt;!-- Item Image --&gt;            &lt;div class="catItemImageBlock"&gt;                &lt;span class="catItemImage"&gt;                    &lt;a href="&lt;?php echo $this-&gt;item-&gt;link; ?&gt;" title="&lt;?php if(!empty($this-&gt;item-&gt;image_caption)) echo $this-&gt;item-&gt;image_caption; else echo $this-&gt;item-&gt;title; ?&gt;"&gt;                        &lt;img src="&lt;?php echo $this-&gt;item-&gt;image; ?&gt;" alt="&lt;?php if(!empty($this-&gt;item-&gt;image_caption)) echo $this-&gt;item-&gt;image_caption; else echo $this-&gt;item-&gt;title; ?&gt;" style="width:&lt;?php echo $this-&gt;item-&gt;imageWidth; ?&gt;px; height:auto;" /&gt;                    &lt;/a&gt;                &lt;/span&gt;            &lt;div class="clr"&gt;&lt;/div&gt;            &lt;/div&gt;&lt;?php endif; ?&gt;

 

You can make a change to that statement and load the default image you want when there is no Image present. It shouls look like this:

 

&lt;?php if($this-&gt;item-&gt;params-&gt;get('catItemImage') &amp;&amp; !empty($this-&gt;item-&gt;image)): ?&gt;             &lt;!-- Item Image --&gt;             &lt;div class="catItemImageBlock"&gt;                 &lt;span class="catItemImage"&gt;                     &lt;a href="&lt;?php echo $this-&gt;item-&gt;link; ?&gt;" title="&lt;?php if(!empty($this-&gt;item-&gt;image_caption)) echo $this-&gt;item-&gt;image_caption; else echo $this-&gt;item-&gt;title; ?&gt;"&gt;                         &lt;img src="&lt;?php echo $this-&gt;item-&gt;image; ?&gt;" alt="&lt;?php if(!empty($this-&gt;item-&gt;image_caption)) echo $this-&gt;item-&gt;image_caption; else echo $this-&gt;item-&gt;title; ?&gt;" style="width:&lt;?php echo $this-&gt;item-&gt;imageWidth; ?&gt;px; height:auto;" /&gt;                     &lt;/a&gt;                 &lt;/span&gt;             &lt;div class="clr"&gt;&lt;/div&gt;             &lt;/div&gt;

&lt;?php else : ?&gt;

&lt;div class="catItemImageBlock"&gt;                 &lt;span class="catItemImage"&gt;                     &lt;a href="&lt;?php echo $this-&gt;item-&gt;link; ?&gt;" title="&lt;?php echo $this-&gt;item-&gt;title; ?&gt;"&gt;                         &lt;img src="YOUR_IMAGE_SOURCE" alt=""  /&gt;                     &lt;/a&gt;                 &lt;/span&gt;             &lt;div class="clr"&gt;&lt;/div&gt;             &lt;/div&gt;

&lt;?php endif; ?&gt;

 

Put your default image to the template images or wherever you want and put the path to the src of the img.
  • ansi.alpha
  • ansi.alpha's Avatar
25 Feb 2011 14:36
Replied by ansi.alpha on topic Image cache questions

Image cache questions

Category: English K2 Community

if anyone still need another solution , you might try this.i made it to when i transferred my wordpress to joomla k2 "troublesome".1. make php file at the top of your joomla directory. "anything.php"2.copy and paste the code in it then check it in your browser and wait until it finish loading.3. when it finish loading, change the 2nd parameter of recreateImg function in the while loop with the k2 Width you variable you want.4.if you get error memory limit reach just refresh and it will continue from where it stop."it happens if your image has really high size"5.delete this php file when you are done creating all images you want.

NOTE: this doesn't create md5 names of images but it could with abit coding. and if your imagesdosn't have md5 names,your images wont work in your k2.&lt;?php/** * $XS,$S,$M,$L,$XL,$Generic are k2 widths of new recreateImgd images in px . "you can find them in k2 panel" * you will need them change 2nd parameter of recreateImg function in the while loop after it finish generating files successfully. * probably not the default size setting. * if you change it ,change switch statment numbers to match them. */$XS = 133;$S = 409;$M = 745;$L = 766;$XL = 1066;$Generic = 300;//path to src folder of your images$srcPath = "./media/k2/items/src/";function recreateImg($file, $k2Width){    global $srcPath;    $imgPath = $srcPath . $file;    $imgname = $file;    // if you change k2 widths variables ,    // you will need to change numbers of each case to match them.    switch ($k2Width) {        case 133:            $size = 'XS';            break;        case 409:            $size = 'S';            break;        case 745:            $size = 'M';            break;        case 766:            $size = 'L';            break;        case 1066:            $size = 'XL';            break;        case 300:            $size = 'Generic';            break;    }    // the new image name and path to save it    $save = "./media/k2/items/cache/" . $imgname . '_' . $size . '.jpg';    if (file_exists($save)) {        echo $imgname . '_' . $size . '.jpg' . ' :Image exisit! &lt;br/&gt;';    } else {        $pic = imagecreatefromjpeg($imgPath);        $width = imagesx($pic);        $height = imagesy($pic);        $ratio = $k2Width / $width;        $newHeight = $height * $ratio;        $new_image = imagecreatetruecolor($k2Width, $newHeight);        imagecopyresampled($new_image, $pic, 0, 0, 0, 0, $k2Width, $newHeight, $width, $height);        imagedestroy($pic);        imagejpeg($new_image, $save);        imagedestroy($new_image);    }} // end of function//calling the function while looping each file if its jpg image$folder = opendir($srcPath);while ($file = readdir($folder)) {    if (substr($file, -4) == ".jpg") { //you can do images generations 1 size at one time by changing 2nd parameter .        recreateImg($file, $XS);    }}closedir($folder);?&gt;
  • Jason Brown
  • Jason Brown's Avatar
15 Feb 2011 06:12

Undesired Feature?? - Transparent PNG's convert to jpg and loose transparency

Category: English K2 Community

Don't understand what you mean by the last stage. i have followed on a local host install and it seems to be creating a png and a jpg and still picking the converted png.(this is in the cache folder.)

So how do I get it to recognise the png.


Stephen Austin said:

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-&gt;id).'_XS.png'))
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.png'))
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.png'))
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.png'))
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.png'))
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.png'))
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.png';
else 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';

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-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = md5("Image".$row-&gt;id);
$handle-&gt;Process($savepath);

$filename = $handle-&gt;file_dst_name_body;
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache';

//XLarge image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params-&gt;get('itemImageXL', '800');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Large image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params-&gt;get('itemImageL', '600');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Medium image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params-&gt;get('itemImageM', '400');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Small image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params-&gt;get('itemImageS', '200');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//XSmall image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params-&gt;get('itemImageXS', '100');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Generic image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_Generic';
$imageWidth = $params-&gt;get('itemImageGeneric', '300');
$handle-&gt;image_x = $imageWidth;
$handle-&gt;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!
  • Markus Amanto
  • Markus Amanto's Avatar
09 Feb 2011 13:32
Replied by Markus Amanto on topic Where K2 store articles images in database?

Where K2 store articles images in database?

Category: English K2 Community

Hi all, 

First the disclaimer, I do not consider myself a professional programmer in any sense, more the stubborn trial-and-error kind of guy. Anyhow, this filename thing was really bugging me, mainly for SEO purposes. 

So I dug around some in the code. I usually try to avoid hacks as they can cause trouble at upgrades, but if you want to try the below it did what I wanted it to do for me. As usual, make back-ups of the files below before starting in case you mess up and need to revert.

So, enough with the disclaimers, here it goes (my K2 version by the way 2.4.1).

The basis for the whole thing is that I do not use the field Image Credits (found in K2 Item Editor -&gt; Image) for anything, so decided to use that for file naming purposes. Also I do not have the lightbox function activated so I have not tested if that works with this hack.

1. in administrator/components/com_k2/models/item.php

Line 207, change to:

$handle-&gt;file_new_name_body = $row-&gt;image_credits;

2. components/com_k2/models/item.php

Starting on line 110, add the line:

$myfilename = $item-&gt;image_credits;

Then there are the following 16 lines below that which need to be modified to:

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_XS.jpg')) $item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.$myfilename.'_XS.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_S.jpg')) $item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.$myfilename.'_S.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_M.jpg')) $item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.$myfilename.'_M.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_L.jpg')) $item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.$myfilename.'_L.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_XL.jpg')) $item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.$myfilename.'_XL.jpg'; if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.$myfilename.'_Generic.jpg')) $item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.$myfilename.'_Generic.jpg'; 

3. When uploading a new file in the K2 Editor under Items -&gt; Image in the backend, just make sure to put your filename in the "Item image credits" field (without any .jpg), for example: my_pretty_seo_image

Note: When I started this work I had not yet uploaded any images, so during testing I went in via FTP and erased all image files under media/k2/items/cache/, so I do not know how it works with overwriting existing images.

Now I am a bit mentally exhausted and in need of lunch so I might have forgotten some modification I made, but I hope the above is of some help to you.

/Markus
  • Macrohard
  • Macrohard's Avatar
02 Feb 2011 18:38

Undesired Feature?? - Transparent PNG's convert to jpg and loose transparency

Category: English K2 Community

For those wanting to use Rokstories, there is one final edit to make.  From the RT forums:

You need to edit modules/mod_rokstories/helper.php at lines 273 and 274


        if (file_exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$id).'_'.$image_size.'.jpg')) {
            $image_path = 'media/k2/items/cache/'.md5("Image".$id).'_'.$image_size.'.jpg';
            $images-&gt;image = JURI::Root(true).'/'.$image_path;
 




Just change the .jpg to .png.
  • Macrohard
  • Macrohard's Avatar
02 Feb 2011 09:46

Undesired Feature?? - Transparent PNG's convert to jpg and loose transparency

Category: English K2 Community

I'm not seeing Generic image processing around line 295?  Running K2 2.4.1.

Stephen Austin said:
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-&gt;id).'_XS.png'))
$item-&gt;imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XS.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_S.png'))
$item-&gt;imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_S.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_M.png'))
$item-&gt;imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_M.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_L.png'))
$item-&gt;imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_L.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_XL.png'))
$item-&gt;imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_XL.png';
else 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';

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item-&gt;id).'_Generic.png'))
$item-&gt;imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item-&gt;id).'_Generic.png';
else 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';

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-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = md5("Image".$row-&gt;id);
$handle-&gt;Process($savepath);

$filename = $handle-&gt;file_dst_name_body;
$savepath = JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache';

//XLarge image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_XL';
if (JRequest::getInt('itemImageXL')) {
$imageWidth = JRequest::getInt('itemImageXL');
} else {
$imageWidth = $params-&gt;get('itemImageXL', '800');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Large image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_L';
if (JRequest::getInt('itemImageL')) {
$imageWidth = JRequest::getInt('itemImageL');
} else {
$imageWidth = $params-&gt;get('itemImageL', '600');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Medium image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_M';
if (JRequest::getInt('itemImageM')) {
$imageWidth = JRequest::getInt('itemImageM');
} else {
$imageWidth = $params-&gt;get('itemImageM', '400');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Small image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params-&gt;get('itemImageS', '200');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//XSmall image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_XS';
if (JRequest::getInt('itemImageXS')) {
$imageWidth = JRequest::getInt('itemImageXS');
} else {
$imageWidth = $params-&gt;get('itemImageXS', '100');
}
$handle-&gt;image_x = $imageWidth;
$handle-&gt;Process($savepath);

//Generic image
$handle-&gt;image_resize = true;
$handle-&gt;image_ratio_y = true;
$handle-&gt;image_convert = 'png';
$handle-&gt;file_auto_rename = false;
$handle-&gt;file_overwrite = true;
$handle-&gt;file_new_name_body = $filename.'_Generic';
$imageWidth = $params-&gt;get('itemImageGeneric', '300');
$handle-&gt;image_x = $imageWidth;
$handle-&gt;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!
  • TOTALLNET
  • TOTALLNET's Avatar
12 Nov 2010 14:00
Replied by TOTALLNET on topic Customizing templates: path to background images

Customizing templates: path to background images

Category: English K2 Community

In my first reply .. i said :

I copied the images folders to :
- my template/html/com_k2/images
- my template/images
- root/images

I tried several ways ...

the only difference is that i changed the movies output to "after text full form"

the website is still over development...but the url in question is www.unione.art.br/portal/index.php?option=com_k2&view=item&id=35:swu-entrevista-juliana-wallauer&Itemid=23

Others K2 templates is "still" OK ...
  • TOTALLNET
  • TOTALLNET's Avatar
09 Nov 2010 20:14
Replied by TOTALLNET on topic Customizing templates: path to background images

Customizing templates: path to background images

Category: English K2 Community

ok .. i will tell you what i did :

The structure is :
mytemplate/html/com_k2/
/templates/totallnet/item.php
/templates/totallnet/item_comments_form.php
/templates/totallnet/latest.php
/templates/totallnet/latest_item.php
/templates/totallnet/category.php
/templates/totallnet/category_item.php
/templates/totallnet/category_item_links.php
/templates/totallnet/images/fugue/
/templates/totallnet/images/placeholder/
/templates/totallnet/images/social/
/templates/totallnet/images/system/

Off course all the images are in their respective folders...

The changed that i had made :

In item.php we need that the video appear into the text field and not after text field... so... copy the lines above and put after :

























Its the wrong way ??? .. may i do somothing or everything wrong ??

Ps im not developer.. off course you see my inexperience .. but im a novice joomlas enthusiastics
  • Pablo Martinez
  • Pablo Martinez's Avatar
06 Nov 2010 20:21

Simon, where I get professional support to solve K2 issue?

Category: English K2 Community

Hi Simon,I pay for fix my issue with Gallery in K2 item Page. I need it asap. Where i find out a K2 expert ?Maybe you can help me in this matter. I am really desperate!Despite a lot of changes and follow many tips &amp; tricks from K2 forums, I still no getting any galleries in my items page.The
zip file upload is fine and I can see my images in media/k2/galleries by FTP, my SIG version  is PRO 2.0.5 with correct path to media/k2/galleries.No error message I get, I can't see gallery thumbs in item page. My Joomla is 1.5.21 and PHP 5.2.14NOTE:
If I disable SIG PRO I can see in item page the gallery tag like &lt;gallery&gt;1&lt;/gallery&gt; what means SIG Pro is disable of course, but working therefore. When activated again the tag disappears and the Gallery isn't showed as before.thanks for any help,pablobr
  • Pablo Martinez
  • Pablo Martinez's Avatar
06 Nov 2010 08:15
Gallery in K2 item Issue was created by Pablo Martinez

Gallery in K2 item Issue

Category: English K2 Community

HiDespite a lot of changes and follow many tips &amp; tricks from K2 forums, I still no getting any galleries in my items page.The zip file upload is fine and I can see my images in media/k2/galleries by FTP, my SIG version  is PRO 2.0.5 with correct path to media/k2/galleries.No error message I get, I can't see gallery thumbs in item page. My Joomla is 1.5.21 and PHP 5.2.14NOTE: If I disable SIG PRO I can see in item page the gallery tag like &lt;gallery&gt;1&lt;/gallery&gt; what means SIG Pro is disable of course but working therefore. When activated again the tag disappears and the Gallery isn't showed as before.Any Ideas ?I pay for any support in this matter if an expert can fixed this issue asap for me,thanks,pablobr
Displaying 61 - 80 out of 98 results.

Powered by Kunena Forum