Display Category Image

I am trying to display category images with on each category page directly under the title, above the HTML description. I understand I can display a pic in the HTML, did that on 3.x but looking to do it with the file upload on 4.x. I inserted the following code into the view.tpl template in categoires and the image box shows up exactly where and how I want it, I just can't figure out how to reference it out to the detailed category image.

{assign var="cat_image" value=$category_id|fn_get_image_pairs:'category':'M':true:true}
{include file="common/image.tpl"
images=$cat_image.detailed
no_ids=true
image_id="category_image"
image_width=$settings.Thumbnails.category_lists_thumbnail_width
image_height=$settings.Thumbnails.category_lists_thumbnail_height
class="ty-subcategories-img"
}
You can see a link to the test page here:
http://http://dsweb.dark-storm.com/dsi/ds-15/
What am I missing on setting the variable? Or is there an easier way to do it?

Try to replace:

images=$cat_image.detailed

with

images=$cat_image

Also please make sure that the $category_id variable is not empty.

I am trying to display category images with on each category page directly under the title, above the HTML description. I understand I can display a pic in the HTML, did that on 3.x but looking to do it with the file upload on 4.x. I inserted the following code into the view.tpl template in categoires and the image box shows up exactly where and how I want it, I just can't figure out how to reference it out to the detailed category image.

{assign var="cat_image" value=$category_id|fn_get_image_pairs:'category':'M':true:true}
{include file="common/image.tpl"
images=$cat_image.detailed
no_ids=true
image_id="category_image"
image_width=$settings.Thumbnails.category_lists_thumbnail_width
image_height=$settings.Thumbnails.category_lists_thumbnail_height
class="ty-subcategories-img"
}
You can see a link to the test page here:
What am I missing on setting the variable? Or is there an easier way to do it?

Try this code:

{include file="common/image.tpl"
                            show_detailed_link=false
                            images=$category_data.main_pair
                            no_ids=true
                            image_id="category_image"
                        }

Try this code:

{include file="common/image.tpl"
                            show_detailed_link=false
                            images=$category_data.main_pair
                            no_ids=true
                            image_id="category_image"
                        }

Winner! Thank you for the help.

Hi,

I have one problem. I uploaded big size category images but after few minutes changing small images. In admin side, I am already set default sizes in category images but it shows very less size images compare to default sizes. I don't know "This is coding problem or admin side problem". How to fix it.

Regards,

naga mahesh bondada,

maheshbondada2@gmail.com.

Please try:

{include file="common/image.tpl"
                            show_detailed_link=false
                            images=$category_data.main_pair
                            no_ids=true
                            image_id="category_image"
                            image_width=$settings.Thumbnails.category_lists_thumbnail_width
                            image_height=$settings.Thumbnails.category_lists_thumbnail_height
}

Please try:

{include file="common/image.tpl"
                            show_detailed_link=false
                            images=$category_data.main_pair
                            no_ids=true
                            image_id="category_image"
                            image_width=$settings.Thumbnails.category_lists_thumbnail_width
                            image_height=$settings.Thumbnails.category_lists_thumbnail_height
}

Please mention the path. Which place to add this code clearly?

\design\themes\responsive\templates\views\categories\view.tpl

Here is what I ended up adding in the end...

{if $category_data.main_pair}
{include file="common/image.tpl"
show_detailed_link=false
images=$category_data.main_pair
no_ids=true
image_id="category_image"
}
{/if}

You are right. To specify image dimensions you should add image_height and image_width parameters:

image_width=$settings.Thumbnails.category_lists_thumbnail_width
image_height=$settings.Thumbnails.category_lists_thumbnail_height

or

image_width=400
image_height=200

Hi,

I would like to add category image on navigation menu (CSCart 4.3.6).
I tried to add this code on topmenu_dropdown.tpl but it doesn't work :
{include file="common/image.tpl"
show_detailed_link=false
images=$category_data.main_pair
no_ids=true
image_id="category_image"
image_width=$settings.Thumbnails.category_lists_thumbnail_width
image_height=$settings.Thumbnails.category_lists_thumbnail_height
class="ty-subcategories-img"
}

There is a code similar to this one which depends on the submenu type (1 column or multicolums):

{foreach from=$item1.$childs item="item2" name="item2"}
   
  • {assign var="item ....}
  • Try to add the following code after it:

                                                 {if $item2.category_id}
                                                    {$main_pair = $item2.category_id|fn_get_image_pairs:'category':'M':true:true}
                                                    {if $main_pair}
                                                        
                                                        {include file="common/image.tpl"
                                                            show_detailed_link=false
                                                            images=$main_pair
                                                            no_ids=true
                                                            image_id="category_image"
                                                            image_width=100
                                                            image_height=70
                                                            class="ty-subcategories-img"
                                                        }
                                                        
                                                    {/if}
                                                {/if}
    

    Thanks for your answer.

    I tried it but it doesn't work (images are empty)

    1st level :

    {assign var="main_pair" value=$item1.category_id|fn_get_image_pairs:'category':'M':true:true}
                                            {include file="common/image.tpl"
                                                show_detailed_link=false
                                                images=$main_pair
                                                no_ids=true
                                                image_id="category_image"
                                                image_width=$settings.Thumbnails.category_lists_thumbnail_width
                                                image_height=$settings.Thumbnails.category_lists_thumbnail_height
                                                class="ty-subcategories-img"
                                            }

    2nd level :

    {assign var="main_pair" value=$item2.category_id|fn_get_image_pairs:'category':'M':true:true}
                                            {include file="common/image.tpl"
                                                show_detailed_link=false
                                                images=$main_pair
                                                no_ids=true
                                                image_id="category_image"
                                                image_width=$settings.Thumbnails.category_lists_thumbnail_width
                                                image_height=$settings.Thumbnails.category_lists_thumbnail_height
                                                class="ty-subcategories-img"
                                            }

    Hmmm... Worked on my demo. Please PM me temporary FTP access so that we can check the issue