0

I would like to customize the detail view of the catalog products. First of all, I want to output the product´s base image separately as a header image. What is the best way to achieve this? I am grateful for any advice!

1 Answer 1

0

I solved the task as follows:

app/design/frontend/< Vendor >/< theme >/Magento_Catalog/layout/catalog_product_view.xmlcatalog_product_view.xml

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        ---
        <block class="Magento\Catalog\Block\Product\View" name="product.header.theme" template="Magento_Catalog::product_header_theme.phtml" />
        ---
    </body>
</page>

app/design/frontend/< Vendor >/< theme >/Magento_Catalog/templates/product_header_theme.phtml

<?php $product =  $block->getProduct(); ?>

<img src="<?= /* @noEscape */ $product->getMediaConfig()->getMediaUrl($product->getImage());  ?>"
     alt="<?= $product->getName(); ?>" />

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.