Using Category Thumbnails as Links in Magento

categorylinkthumbnail

Is it possible to use the sub-category thumbnails as a link to the category? So that you can click the thumbnail instead of the text, if yes, can you then also remove the text?

Best Answer

Create a static block with the code: subcategories and insert:

{{block type="core/template" template="catalog/category/sub.phtml"}}

Create catalog/category/sub.phtml

<?php
$category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
$categories = $category->getCollection()
        ->addAttributeToSelect(array('name', 'thumbnail'))
        ->addAttributeToFilter('is_active', 1)
        ->addUrlRewriteToResult()
        ->addIdFilter($category->getChildren())
?>
<ul class="subcategories">
    <?php foreach ($categories as $category): ?>
        <li>
            <a href="<?php echo $category->getUrl() ?>"><img src="<?php echo Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . $category->getThumbnail() ?>" alt="<?php echo $this->htmlEscape($category->getName()) ?>" />
                <span><?php echo $category->getName() ?></span></a>
        </li>
    <?php endforeach; ?>
</ul>

Now assign and set whatever root category you want to show its sub categories as their thumbnails with the assigned subcategories CMS Block created. Make sure Display mode is set to either Static block only or Products and Static block.

Source:

In order to resize the category icons/thumbnails you'll need this:

Resize Category Images:

With the above installed the change to make is:

<?php //echo Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . $category->getThumbnail() ?>
<img src="<?php echo $this->helper('timage')->init(Mage::getBaseUrl('media') . 'catalog' . DS . 'category' . DS . $category->getThumbnail())->resize(null, 140) ?>" width="140" height="140" alt="<?php echo $this->htmlEscape($category->getName()) ?>" />