We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    If you want to show sub category image with sub category name of current category page then follow below process.

    Get subcategory of current category

    Step 1 : create sub-category.phtml file under ../app/design/frontend/[VendorName]/[theme]/Magento_Catalog/templates/category/

    and paste below code inside it

    <?php
        $objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $category = $objectManager->get('MagentoFrameworkRegistry')->registry('current_category');    //get current category
        $subcategories = $category->getChildrenCategories();
        $_helper = $this->helper('MagentoCatalogHelperOutput');
    ?>
    
    <ul class="sub-category">
        <?php
        foreach ($subcategories as $sub_category) {
                $_category = $objectManager->create('MagentoCatalogModelCategory')->load($sub_category->getId());
                $_outputhelper = $this->helper('MagentoCatalogHelperOutput');
                $subcategoryurl = $sub_category->getUrl();            
                $catimgHtml = '';
                echo '<li>';
                if ($catimgUrl = $_category->getImageUrl()) {
                    $catimgHtml = '<img src="' . $catimgUrl . '" />';
                    $catimgHtml = $_outputhelper->categoryAttribute($_category, $catimgHtml, 'image');
                    /* @escapeNotVerified */
                    echo '<a href="' . $subcategoryurl . '" title="' . $sub_category->getName() . '">' . $catimgHtml . '</a>';
                }
                echo '<h2><a href="' . $subcategoryurl . '" title="' . $sub_category->getName() . '">' . $sub_category->getName() . '</a></h2>';
                echo '</li>';
        } ?>
    </ul>

     

    Step 2 : Add below mention code in ../app/design/frontend/[VendorName]/[theme]/Magento_Catalog/layout/catalog_category_view.xml

    <referenceContainer name="columns.top">
        <!-- Add this below code -->
        <container name="category.view.customcatlink" htmlTag="div" htmlClass="custom-category-link" before="category.view.container">
            <block class="MagentoCatalogBlockCategoryView" name="custom.category.links" template="Magento_Catalog::category/custom-cat-links.phtml"/>
        </container>

     

    After that run below commands

    – php bin/magento setup:upgrade
    – php bin/magento setup:di:compile
    – php bin/magento cache:clean

    That’s it.

    Now, sub category image with sub category name will show on list page.

    field_5bfb909c5ccae

      Get a Free Quote