I'm trying to build mobile image gallery for product using Magento resize function.
Everything works fine - code displays 4 pictures (there is 4 pictures for this product in backend), but all 4 displayed pictures are last image of a product.
Example:
In admin I have
Image 1 Image 2 Image 3 Image 4
Result I get is:
Image 4 Image 4 Image 4 Image 4
Result I want to achieve should be:
Image 1 Image 2 Image 3 Image 4
Any pointers would be more than appreciate.
Please see code below:
<?php
$product_id = $this->getProduct()->getId();
$product = Mage::getModel('catalog/product')->load($product_id);//product id here
$galeries = array();
foreach($product->getMediaGalleryImages() as $image){
$image_path = $image->getPath();
if(!file_exists($image_path)) continue;
$galeries[$image->getLabel()]['images'][]['url']=$image->url;
$correctURL = $this->helper('catalog/image')->init($this->getProduct(), 'small_image', $image->getFile())->resize(750,750);
if( $image->associated_attributes != ''){
$idForSlider = explode('-',$image->associated_attributes);
$idForSlider = $idForSlider[1];
$idForSlider = 'swatches_option_value_'.$idForSlider;
$galeries[$image->getLabel()]['idForSlider']=$idForSlider;
}
}
foreach ($galeries as $galery){
$idForOwl = $n;
$n++;
?>
<div class="v-slider<?php echo ($idForOwl+1)?>">
<div id="owl-demo<?php echo ($idForOwl+1)?>" class="owl-carousel" style="">
<?php
foreach ($galery['images'] as $image) {
?>
<div class="item">
<img src="<?php echo $correctURL?>" width="750" height="750">
</div>
<?php
}
?>
</div>
</div>
<?php
}
?>