-4
$_category->getImageUrl()

I want to know why this is used. and where we can use this

2 Answers 2

1

This is the function to get Magento catalog categories image. You can use this function anywhere in the View file.

Here is the code will work for you any phtml file.

 $categoryID = 3; //category ID
 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 $_category = $objectManager->create('Magento\Catalog\Model\Category')->load($categoryID);
 $_imgUrl = $_category->getImageUrl();
 <img alt="" src="<?php echo $_imgUrl; ?>" class="max-width50 img-fluid mx-auto">

I hope it will help you.

Thanks

-1

This is for Getting category thumbnail.

Magento provides facilities to get the Image URL from a category by using the catalog/category model.

You can get the category thumbnail image by

$_category->getImageUrl()
2
  • 1
    why do you ask a question that you already know the answer in the first place? Or maybe you are trying to post or share a piece of knowledge.
    – fmsthird
    Commented Feb 25, 2019 at 13:19
  • 1
    Before I don't know the exact answer but when I got an answer, to share the knowledge I posted it. Commented Feb 25, 2019 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.