I am using Magento version.

I want to get and show the Product Image section as like Product Detail Page in my custom phtml.

How to get it.

enter image description here

Update: my layout.xml file content:

<block type="custom/myblock" name="custom_myblock" after="-" template="custom/mytemplate.phtml">
    <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml">
                <block type="core/text_list" name="product.info.media.after" as="after" />

And Calling in mytemplate.phtml as follows:

<div class="product-view">
    <div class="product-img-box">
            <div class="product-name">
                <h1><?php echo $_helperOutput->productAttribute($product, $product->getName(), 'name') ?></h1>
            <?php echo $this->getChildHtml('media') ?>

and Getting this error: Fatal error: Call to a member function getTypeInstance() on null in ../app/code/core/Mage/Catalog/Block/Product/View/Abstract.php on line 44

2 Answers 2


Use below code in your layout.xml

        <reference name="content">
            <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>

Then in your controller action file use below code

public function indexAction() {
    $product = Mage::getModel('catalog/product')->load(408); // set product id here
    Mage::register('current_product', $product);
    Mage::register('product', $product);
    $this->_title(Mage::helper('confirmnl')->__('Product image'));

It will display product image block on your page url.

TO soleve getTypeInstance error you need to add current_product in controller


As per the RWD theme in Magento, this section renders by catalog_product_gallery layout which you can find it from


and the main PHTML file is responsible for this section is catalog/product/gallery.phtml and the main Block is Mage_Catalog_Block_Product_Gallery so just take a look at this sections and try.

If you are using some custom theme then please check your theme layout file and PHTML file.

  • I am using custom theme and Created layout and Phtml. But the images not rendering. Commented Dec 22, 2017 at 8:06
  • What is your block type of PHTML file ?
    – Keyur Shah
    Commented Dec 22, 2017 at 8:08
  • Updated Question. Pls check it. Commented Dec 22, 2017 at 8:09

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.