0

I found the answer to this for Magento 1.x, but I can't find a 2.0x solution.

On my category pages, before the products are shown, there is a huge image, "category-image".

Does anyone know where the phtml file is that loads this image?

Thanks so much!

1
  • It would be great if you can share screen shot that may help me to understand which image of category are you talking about.
    – Aman Alam
    Commented Jun 22, 2016 at 18:16

3 Answers 3

2

You can find this in your theme

app\design\frontend\{packagename}\{themename}\Magento_Catalog\templates\category\image.phtml

If you don't find the file here then you can create your own with same name having content:

<?php
    $_helper    = $this->helper('Magento\Catalog\Helper\Output');
    $_category  = $block->getCurrentCategory();
    $_imgHtml   = '';
    if ($_imgUrl = $_category->getImageUrl()) {
        $_imgHtml = '<div class="category-image"><img src="' . $_imgUrl . '" alt="' . $block->escapeHtml($_category->getName()) . '" title="' . $block->escapeHtml($_category->getName()) . '" class="image" /></div>';
        $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
        /* @escapeNotVerified */ echo $_imgHtml;
    }
?>

and you can modify it as you want. :)

Magento uses fallback method so this file is initially placed in Magento_Catalog::view/frontend/templates/category/image.phtml
You can overwrite it in your theme.

1
  • Thanks so much for this help. I had found this file earlier, and assumed this was what I needed to change, but was unsure on how to completely remove the image without causing a broken link. Commented Jun 22, 2016 at 19:56
1

Go to vendor\magento\module-catalog\view\frontend\templates\category and look for file image.phtml. This file is responsible to display Category image before rendering products. You can override this file in your magento designed theme, and can modify as per your requirements.

0

Go to app/design/frontend/vendor/theme/Magento_Catalog/layout/catalog_category_view.xml and remove block with xml code

<referenceBlock name="category.image" remove="true"/>
<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="sidebar.main">
            <referenceBlock name="category.image" remove="true"/>
        </referenceContainer>
    </body>
</page>

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.