【发布时间】:2015-09-08 11:42:17
【问题描述】:
我正在为每个产品上传大约 30 张图片,其数字名称如下:
001.png 002.png 003.png ....
但上传后会在前端显示
002.png 003.png 001.png ....
如何在前端自动排序以下是 Magento media.phtml 中的一段代码
<ul class="product-image-thumbs">
<?php foreach ($this->getGalleryImages() as $_image):?>
<li>
<a href="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $_image->getFile()); ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>" rel="prettyPhoto[mixed]">
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($_thumbWidth, $_thumbHeight); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
</a>
</li>
<?php endforeach?>
<?php if ($_360IsSet && !$_embedded):?>
<?php $_360ViewWidth = preg_replace("/[^0-9]/", "", $_360ViewWidth) ?>
<?php $_360ViewHeight = preg_replace("/[^0-9]/", "", $_360ViewHeight) ?>
<li>
<a href="<?php echo $this->getSkinUrl('webrotate360/frame_' . $_viewerSkin . '.html') . '?iframe=true&width=' . $_360ViewWidth . '&height=' . $_360ViewHeight ?>" rel="prettyPhoto[mixed]">
<img src="<?php echo $_360icon ?>" />
</a>
</li>
<?php endif?>
</ul>
【问题讨论】:
-
据我所知没有自动排序,修改
getGalleryImages以获得您需要的顺序可能会更容易。 -
感谢@WhiteHat 的回复,我已经用 jquery 解决了这个问题:)
-
酷,你会发布你的答案吗?我和其他人希望看到...
标签: javascript php magento-1.9