我的产品图片的宽度范围很大。固定大小的水印会使它在一些太小的图像上变得愚蠢。通过产品图像的百分比调整Magento水印的大小?
我看到有一个选项可以指定水印在产品图像上打印的绝对像素的实际宽度,但有什么方法可以使用百分比而不是绝对值来使用水印吗?如原始图像宽度的35%,然后按比例调整大小。你明白了。
有什么想法?
非常感谢!
我的产品图片的宽度范围很大。固定大小的水印会使它在一些太小的图像上变得愚蠢。通过产品图像的百分比调整Magento水印的大小?
我看到有一个选项可以指定水印在产品图像上打印的绝对像素的实际宽度,但有什么方法可以使用百分比而不是绝对值来使用水印吗?如原始图像宽度的35%,然后按比例调整大小。你明白了。
有什么想法?
非常感谢!
现在,我可以得到width of product images在Magento:
$this->helper('catalog/image')->init($_product, 'image')->getOriginalWidth()
我可以即时计算水印宽度:
$watermarkWidth = $this->helper('catalog/image')->init($_product, 'image')->getOriginalWidth() * .5; // watermark width will be 50% of the original image width
,然后计算$ watermarkHeight,水印由高度比例。
随着setWatermarkSize()方法,我可以用原始图像的比例现在设置水印:
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->setWatermarkSize($watermarkWidth.'x'.$watermarkHeight);?> />
是你能得到这个上的图像画廊,或只是在主图像上工作?
我以前在media.phtml下面来调整水印:
<?php
$_originalWidth = $this->helper('catalog/image')->init($_product, 'image')->getOriginalWidth();
function iGetWatermarkSize($_originalWidth) {
//Change the width value percentage to be what percent you want the watermark to be of the image - I want it to not display or display very small so I used .05, otherwise I would have used .9
$_watermarkSizeWidth = .05 * $_originalWidth;
$_watermarkSizeHeight = $_watermarkSizeWidth * 54/574;
$_watermarkSize = $_watermarkSizeWidth.'x'.$_watermarkSizeHeight;
return $_watermarkSize;
}
$_watermarkSize = iGetWatermarkSize($_originalWidth);
$_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image')->setWatermarkSize($_watermarkSize).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
echo $_helper->productAttribute($_product, $_img, 'image');
?>
我不确定如何得到它的一个画廊图像上工作。