php - how to change image URL for each image of 4 products on each row? -
i have dynamic product table 4 product on each row. i'm using css , not html table. i'm looking way change 4 images on each row different urls , same on other rows.
the reason use 4 sub domains cdn allow faster downloads.
is possible? i'm still junior need assistance.
below code , image section <img class="lazy" src="/images/loading.gif" data-original="<?=resize($i['image'],$settings)?>" width="170" height="250" alt="" />
notice i'm using data-original i'm using lazyload, $settings used creating cached version of image.
here's code...
if($viewing=='retailer'){ if($i['category']!=$categorycheck){?> <div id="sub-sub"><?=$i['category_name']?></div> <? $categorycheck = $i['category']; $y=1; }?><? } ?> <div class="package"<?=$y==4?' style="margin-right:0;"':''?><?=$y==1?' style="clear:left;"':''?>> <div class="package-img"><a rel="nofollow" target="_blank" href="<?=$buylink?>"> <?php $settings = array('w'=>170,'h'=>250,'canvas-color'=>'#ffffff'); ?> <img class="lazy" src="/images/loading.gif" data-original="<?=resize($i['image'],$settings)?>" width="170" height="250" alt="" /> <noscript><img src="<?=resize($i['image'],$settings)?>" width="640" heigh="480"></noscript> <? /* <img src="<?=$i['image']?>" width="640" heigh="480"> */ ?> </a></div> <div class="name"><a rel="nofollow" target="_blank" href="<?=$buylink?>"><?=$i['item_name']?></a></div> <div class="price"><p>£<?=$i['price']?></div> <a href="<?=$buylink?>"><div class="mrtl rtl<?=$i['retailer']?>"></div></a> <div class="retailer-image"><a href="<?=$buylink?>"><img src="/images/retailers/<?=$i['retailer_logo']?>" width="140" heigh="46" /></a></div> </div> <? $y = $y==4 ? 1 : $y+1; }
you need change function returns path image.
<?php function resize(..., ...) { static $i = 0; $i++; if ($i == 5) { $i = 1; } return "http://cdn{$i}.domain/images/blah.gif"; } ?>
Comments
Post a Comment