I was able to solve it. I am pasting the code below for what i did.
Step 1 : Created an helper file and have added this code in there
<?php
class Greeting_Products_Helper_Data extends Mage_Core_Helper_Abstract
{
function altImage($product, $val, $w, $h, $imgVersion='small_image'){
$product->load('media_gallery');
$column = 'position';
$value = $val;
$gal = $product->getMediaGalleryImages();
if ($gal = $product->getMediaGalleryImages())
{
if ($altImg = $gal->getItemByColumnValue($column, $value))
{
return
'<img class="alt-img lazyOwl" style="display:none;" src="' . $this->getImg($product, $w, $h, $imgVersion, $altImg->getFile()) . '" alt="' . $product->getName() . '" />';
}
}
return '';
}
}
?>
Please review the code. It will pretty much explain everything.
To call the alternative image use the following code :
echo $this->helper('greeting_products')->altImage($_product,2,220,220);
Here 2 is the position of image and rest are the image parameters