Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Get K2 category image on category page

Get K2 category image on category page

Hi

I need to get Category image under condition:

Code:

if ($k2->check("pagetype == category.latest")) 

In joomgenius/k2.php I read:
   

Code:

function itemInfo( $type ) {

        $pageType = $this->pageType();
       
        switch ($pageType) {
             ....
               
            // We should really allow the category_* things to be queried on category
            // pages as well as item.view pages. For a later date...
           
            ...
        }
    }

Any idea to solve it?

thanks in advance

editartgroup
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Get K2 category image on category page

And K2 item image under item page?

Thanks again

editartgroup
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

Re: Get K2 category image on category page

Hi,

regarding getting the item image: this isn't actually held in the database, but the image file is simply stored on the server and named using the md5 hash of the K2 item id.

I found this in the K2 source:

if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$nextItem->id).'_XS.jpg'))
{
  $item->nextImageXSmall = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$nextItem->id).'_XS.jpg';
}

The sizes are XS, S, M, L, XL and Generic so you can get hold of whichever one you want. The code above will get hold of the URL for the image.

If you get hold of the K2 item id then you can sub that in instead of "$nextItem->id" above.
The original actually does some tricky things with the timestamp of the image in order to defeat caching if images have changed, but I removed those for the example above.

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3319 Posts
User info in posts
Administrator has disabled public posting

Re: Get K2 category image on category page

Category image:

$path = '/media/k2/categories/'.$category_id.'.jpg';
if (JFile::exists(JPATH_SITE.$path)) {
  $url = JURI::root(true).$path;
} else $url = '';

I trust this will work. It assumes the file is a jpg. Ideally this info should be gotten from the K2 categories table in the database but from what I can see, the images are simply indexed by the category id number (which you will need for the code above to work, and you can get this from JomGenius).

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3319 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1674
Total Polls:
6
Total Posts:
5917
Total Posts Today:
5
User Info:
 
Total Users:
11538
Newest User:
michael2155
Members Online:
2
Guests Online:
232


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked