我找到了这个模块,它对产品图像使用自适应调整大小。 https://github.com/wearefarm/magento-adaptive-resize
现在我想弄清楚,如何在 Magento 中的任何其他图像上使用自适应调整大小功能? 我试着这样调用它,但它没有用:
<?php $imager = $this->getSkinUrl('images/thumb_image/something-something.jpg');
$imager = Mage::helper('catalog/image')->AdaptiveResize(100,200);?>
最佳答案
没关系,我找到了解决方案。我创建了一个带有助手的自定义模块,其中包含来自第三方脚本 Zebra Image 的函数 http://stefangabos.ro/php-libraries/zebra-image/
这是我在 Helper 文件夹中创建的 Data.php 文件:
class yokubo_customContent_Helper_Data extends Mage_Core_Helper_Abstract{
public function resize($img,$target) {
$ExternalLibPath=Mage::getModuleDir('lib', 'yokubo_customContent'). DS . 'lib' . DS .'Zebra_Image.php';
require_once ($ExternalLibPath);
$image = new Zebra_Image();
$image->source_path = $img;
$image->target_path = $target;
$image->jpeg_quality = 100;
$image->preserve_aspect_ratio = true;
$image->enlarge_smaller_images = true;
$image->preserve_time = true;
$image->resize(300, 300, ZEBRA_IMAGE_CROP_CENTER);
}
我现在可以在任何地方为任何图像执行它,通过指定图像的路径和目标目录:Mage::helper('customContent')->resize($_imageUrl,$imageResized);
关于php - 如何在 Magento 中的任何图像上使用自适应调整大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21299896/