Jump to content

Using different picture for category & subcategory


Recommended Posts

Hello,

 

If you want to use a different picture for category and use category-thumbnail like subcategory picture it is very simple.

 

You have to add category-thumbnail for your category and you have to change your category.tpl file..

 

replace

 

<img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')|escape:'html':'UTF-8'}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />

 

with


<img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, '0_thumb')|escape:'html':'UTF-8'}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />

 

 

Marius

Link to comment
Share on other sites

and if you want to test if file exists you can replace in your category.tpl

 

<img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')|escape:'html':'UTF-8'}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />

 

 

with

 

 

{if file_exists($smarty.const._PS_ROOT_DIR_|cat:"/img/c/{$subcategory.id_image}-0_thumb.jpg")}
     <img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, '0_thumb')|escape:'html':'UTF-8'}" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />
{else}
     <img class="replace-2x" src="{$img_cat_dir}{$lang_iso}-default-medium_default.jpg" alt="" width="{$mediumSize.width}" height="{$mediumSize.height}" />    
{/if}
 

 

Maybe in the next version we will have "add a subcategory thumbnail" in the category admin page.

 

Regards

Marius

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...