title: Magento, show image on custom frontend block
body: <p>I've a module up and running. On the backend side I can upload images with several attributes and I'm saving image path and other information on a custom table. On frontend I already managed to detect when I need to show these images. I've used an Observer that adds a new layout handle when the displayed product is found on the custom created table. Then on that layout handle I call a phtml template file and from here I call a function inside a block that will be in charge of doing all the checks to be sure wich image to show.</p>
  
  <p>My problem is that I can not find how to show these images. Everything I found references how to add image tag on a phtml file doing some extra verifications on the inserted php code. Buy on my case everything is on php code outside any phtml file.</p>
  
  <p>My phtml file code:</p>
  
  <pre><code>&lt;div&gt;
      &lt;h3&gt;&lt;?php $this-&gt;showCampaign(); ?&gt;&lt;/h3&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My block code for now:</p>
  
  <pre><code>&lt;?php
  class Dts_Banners_Block_Front extends Mage_Core_Block_Template {
  
      /**
       * Shows a campaign banner according to the current selected product
       * Seeks on main banners table to see if it is an image/html/product alone campaign
       * Once knows the campaign type search on needed table the needed fields
       */
      public function showCampaign() {
          //Zend_Debug::dump($this-&gt;getLayout()-&gt;getUpdate()-&gt;getHandles());
  
          $product = Mage::registry('current_product');
          $currentProdID = $product-&gt;getId();
  
          if (Mage::registry('campaign_data') &amp;&amp; Mage::registry('campaign_data')-&gt;getId()) {
              $currentCampaign = Mage::registry('campaign_data');
          } else {
              return;
          }
  
          // get campaign type and show needed information  
          switch ($currentCampaign-&gt;getbanner_type()) {
              case 1: // image
                  $myImgCollection = Mage::getModel('banners/bannersimg')-&gt;getCollection();
                  $myImgCollection-&gt;addfieldtofilter('bannerid',$currentCampaign-&gt;getID());
                  $currentImg = $myImgCollection-&gt;getFirstItem();
                  $currentImgPath = $currentImg-&gt;getimg_path();
                  //{{block type="catalog/product_new" product_id="16" template="catalog/product/view/your_new_page.phtml"}}
                  break;
              case 2: // html
                  echo "html";
                  break;
              case 3: // plain product url
                  echo "plain product url";
                  break;
          }
      }
  }
  </code></pre>