Is there a way to check If category has image? I want to show icons for each category individual in Mega Menu.

I want to dynamic add categories in mega menu. Please see attached screenshot.

Any help would be greatly appreciated!


You can check in Category page by using below code.

$_category  = $block->getCurrentCategory(); // get Current Category
$_imgUrl = $_category->getImageUrl()

If $_ImgUrl is not equal to blank means category has image else not.


| improve this answer | |
  • How to show icons for each category? – mageDev0688 Feb 21 '17 at 12:18
  • You have to create image file upload control in category. – Sanjay Jethva Feb 21 '17 at 12:22
  • I have create the image for each category, but I not getting the image URL yet. I am using the below extension for display the categories on the home page. github.com/ibnab/magento2-home-categories – mageDev0688 Feb 21 '17 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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