Get Category Image to front-end from custom category attribute created through attribute manager
-
29-09-2020 - |
Question
I have just created a custom attribute for categories through Attribute Manager, with attribute code category_view_img
.
Now I can only put one image into a category, and use this image for both the banner and category-view-image on the home page. I want to use this custom attribute image on the home page as category view image. How can I get this image on front-end?
I am new to Magento and I don't have ideas how to do this, please assist. I am using Magento 1.9.2.3.
Solution 2
After spinning my head regularly throughout all over Internet, I finally found a solution for this issue:
var $image= trim(Mage::getBaseUrl('media').'catalog/category/'.$_category->getData('category_view_img'));
<img src="<?php echo $image;?>"/>
I hope this helps someone.
OTHER TIPS
Use below code:
<?php $category = Mage::getModel('catalog/category')->load('category-id'); ?>
<img src="<?php echo $category->getCategoryViewImg(); ?> />
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange