How to add block near a product image in a product detail page in Magento 2


2 Answers 2


Add below code in \view\frontend\layout\catalog_product_view.xml and clean cache

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="product.info.media">
        <container name="" htmlTag="div" htmlClass="" before="skip_gallery_after.target">
            <block class="" name="" template="" />

Add below code and change block identifier name


<referenceContainer name="content">
            <block class="Magento\Cms\Block\Block" name="block-identifier" before="product.info.media">
                    <argument name="block_id" xsi:type="string">block-identifier</argument>

Clear cache and check..

  • i want to add a block in custom module Commented May 14, 2019 at 5:42
  • via xml or phtml ?? Commented May 14, 2019 at 5:43
  • add a layout in xml Commented May 14, 2019 at 5:45
  • If you have created custom module, you can use my code as i mention in above answered. just have to use module layout xml file. Commented May 14, 2019 at 5:47

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.