I was Created one Custom Module. In that Module Image uploaded from the Backend Side, now I want to Fetch Image on Frontend Side not image name. Can Any one help me? Any kind of help will appreciated.

Here is my phtml file :

     $collection = Mage::getModel('recipe/recipe')->getCollection();


    <?php   echo "<table border=2>
            <th><b>Category Id</th>
            <th><b>Category Name</th>
            <th><b>Category Slug</th>
            <th><b>Category Image</th>
            <th><b>Parent Category</th>
            <th><b>Creation Time</th>
            <th><b>Update Time</th>

    foreach($collection as $data)

            <td><?php echo $data->getId(); ?>
                <td><?php echo $data->getCategoryName();?>
                <td><?php echo $data->getCategorySlug();?>

                <td><?php echo $data->getCategoryImage();?></td>
                <td><?php echo $data->getParentCategory();?>
                <td><?php echo $data->getCreatedTime();?>
                <td><?php echo $data->getUpdateTime();?>
                <td><?php echo $data->getStatus();?>




And also in database my image filed name is category_image

  • are you saving image in DB? Dec 29, 2016 at 5:38
  • @Ashish Madankar : yes I am saving image in DB. but only image name. Dec 29, 2016 at 5:40
  • @H_Parekh can you provide code and database detail so anyone can understand better your scenario Dec 29, 2016 at 6:15
  • @ Murtuza Zabuawala : I am Edit my question , now you can see code. Dec 29, 2016 at 6:39
  • Where are you saving your images?
    – Piyush
    Dec 29, 2016 at 7:01

2 Answers 2


in your td please try below code

  <td> <img src="<?php echo Mage::getBaseUrl('media/category_image'). $data->getCategoryImage(); ?>">

and If your image is in root directory of media then image will appeared

  • :my image directory is media/category_image Dec 29, 2016 at 7:05
  • @H_Parekh check updated answer Dec 29, 2016 at 7:06
  • @H_Parekh You are always welcome :) Dec 29, 2016 at 7:22

You can load your module

$model = Mage::getModel('vendor/model')->load(the required id);

Then You can call the Image Field for Example your Field name is image in DB

$model->getImage() // this will give you image name 

Then In your phtml file you can create img tag to display

$imagePath = Mage::getBaseUrl('media') . 'vendorName/';
<img src="<?php $imagePath.$model->getImage() ?>" alt="<?php $model->getTitle() ?>"/>

Note: I have given an example so the following image should be in such dir

<magento root>/media/vendorName/Image.jpg

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.