im trying to add a thumbnail image to aw blog posts header and into the aw blog sidebar widget next to the each headline

i did these:

In app/code/community/AW/Blog/Block/Manage/Blog/Edit/Form.php


$form = new Varien_Data_Form(array(
    'id' => 'edit_form',
    'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
    'method' => 'post',


$form = new Varien_Data_Form(array(
    'id' => 'edit_form',
    'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
    'method' => 'post',
    'enctype' => 'multipart/form-data'

In app/code/community/AW/Blog/Block/Manage/Blog/Edit/Tab/Form.php


$fieldset->addField('featured_image', 'image', array(
    'name' => 'featured_image',
    'label' => 'Featured Image'

below the line

$fieldset = $form->addFieldset('blog_form', array('legend' => Mage::helper('blog')->__('Post information')));

In app/code/community/AW/Blog/controllers/Manage/BlogController.php


if(isset($_FILES['featured_image']['name']) and (file_exists($_FILES['featured_image']['tmp_name']))) {
   try {
      $uploader = new Varien_File_Uploader('featured_image');

      // setAllowRenameFiles(true) -> move your file in a folder the magento way
      // setAllowRenameFiles(true) -> move your file directly in the $path folder

      $path = Mage::getBaseDir('media') . DS ;

      $uploader->save($path, $_FILES['featured_image']['name']);

      $data['featured_image'] = $_FILES['featured_image']['name'];
   }catch(Exception $e) {


// handle delete image
else {
   if(isset($data['featured_image']['delete']) && $data['featured_image']['delete'] == 1)
      $data['image_main'] = '';

below the line

$model = Mage::getModel('blog/post');

And added a "featured_image" column to the aw_blog table in database. Use the type VARCHAR(255) default null and null enable .

and add

<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$post->getFeaturedImage() ?>



below line

<?php foreach ($posts as $post): ?>
    <div class="postWrapper">
        <div class="postTitle">
            <h2><a href="<?php echo $post->getAddress(); ?>" ><?php echo $post->getTitle(); ?></a></h2>

but in blogs page image address is showing instead of image

3 Answers 3


If the url is just shown you just need to wrap it in image tags right?

<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).$post->getFeaturedImage() ?>" alt="featuredImage" />
  • how to change the directory from 'media' to 'media/blogpic' ?
    – Moh3n
    Dec 1, 2014 at 21:36
  • please ask this as a new question and specify whether you want the images to be saved in that directory or loaded from that directory Dec 2, 2014 at 20:11
  • Hi @Moh3n , you can change the path like this: $path = Mage::getBaseDir('media') . '/blogpic/' ; May 31, 2017 at 18:53

I have added a little check before

<?php if ($post->getFeaturedImage()): ?>
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'blog/'.$post->getFeaturedImage() ?>" alt="<?php echo $post->getTitle(); ?>" />
<?php endif;?>

For insert in Db "featured_image" column to the aw_blog table in database and insert the type VARCHAR(255) default null and null enable, what is the procedure? Tnx

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.