monsieurbiz / mbiz_imagecrop
一个为 Magento 提供更多图像裁剪功能的模块。
0.1.0
2016-06-27 15:53 UTC
Suggests
- magento-hackathon/magento-composer-installer: Allows to manage this package as a dependency.
This package is auto-updated.
Last update: 2024-08-29 03:36:48 UTC
README
一个简单的辅助工具,用于在 Magento 中裁剪和/或调整图像大小。
如何裁剪
<?php $width = 100; // required argument $height = 200; // optional argument $imagePath = 'foo/bar.png'; // Your image is in the /media directory. In /media/foo/ precisely. // The method of the helper // crop($imageRelativePath, $width, $height = null); $imageUrl = Mage::helper('mbiz_imagecrop')->crop($imagePath, $width, $height);
如何调整大小
<?php $width = 100; // required argument $height = 200; // optional argument $imagePath = 'foo/bar.png'; // Your image is in the /media directory. In /media/foo/ precisely. // The method of the helper // resize($imageRelativePath, $width, $height = null); $imageUrl = Mage::helper('mbiz_imagecrop')->resize($imagePath, $width, $height);
您还可以设置新图像目录的前缀。前缀是一个目录。默认情况下,我们新的图像将被保存到 /media/cache/100x200/hash/b/a/bar.png
。但如果您设置了前缀,如
<?php $imageUrl = Mage::helper('mbiz_imagecrop')->setPrefix('baz')->crop($imagePath, $width, $height);
或
<?php $imageUrl = Mage::helper('mbiz_imagecrop')->setPrefix('baz')->resize($imagePath, $width, $height);
图像将被保存到 /media/baz/cache/100x200/hash/b/a/bar.png
。
祝您玩得开心!