Magento Expert Forum - Improve your Magento experience
-
How to resize images in Magento 1 & 2?
How to resize images in Magento 1 & 2?
Magento search not working
How to create URL redirect in Magento 1 & 2
Please re-run Magento compile command
Magento PWA examples
View more threads in the same category:
- buy a USA/UK passport online( https://legitcleandocs.com)visa, SNN, id card
- buy registered drivers license online(legitcleandocs.com)passport,IELTS certific
- Kubota Special Equipment repair instructions
- buy registered drivers license (legitcleandocs.com)IELTS, id
- Buy Passport,Driver License,Age & ID Card,(Whatsap
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Zw3d|올인 원, 합리적인 가격의 cad/cam 솔루션 | 한컴
- buy real passports online(https://legitcleandocs.com)drivers license, visa, id card
- BUY UNDETECTABLE GRADE A+ COUNTERFEIT BANKNOTE(legitcleandocs.com)
- buy real registered drivers license online(legitcleandocs.com)visa, id card, resident
Last edited by annapham; 09-08-2018 at 07:38 AM.
-
-
Junior Member
Resize images in Magento 1
<code>
<img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail',<br/> $_image->getFile())->backgroundcolor('000', '000', '000')->resize(100); ?>" ... />
</code>
Resize images in Magento 2
<?php
/**
*
* @var \Magento\Catalog\Model\ProductRepository
*/
protected $_productRepository;
/**
*
* @var \Magento\Catalog\Helper\Image
*/
protected $_productImageHelper;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Catalog\Model\ProductRepository $productRepository
* @param \Magento\Catalog\Helper\Image $productImageHelper
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Catalog\Model\ProductRepository $productRepository,
\Magento\Catalog\Helper\Image $productImageHelper,
array $data = []
)
{
$this->_productRepository = $productRepository;
$this->_productImageHelper = $productImageHelper;
parent::__construct($context, $data);
}
/**
* resize of the image
* @see \Magento\Catalog\Model\Product\Image
* @param int $width
* @param int $height
* @return $this
*/
public function resizeImage($id, $image_type, $width, $height = null)
{
$product = $this->_productRepository->getById($id);
$resizedImage = $this->_productImageHelper->init($product, $image_type)
->constrainOnly(TRUE)
->keepAspectRatio(TRUE)
->keepTransparency(TRUE)
->keepFrame(FALSE)
->resize($width, $height);
return $resizedImage;
}
-
-
-
-
If you dont know how to do it yourself, why dont you handover the job to your graphic designer?
-
-
Magento does not have any default resize function for category like product.
So, you need to use Varien_Image class for this purpose.
Team Building Activities in Delhi | Corporate Team Building Games | Corporate Team Building Activities
Last edited by vishnu; 02-05-2019 at 07:11 AM.
-
-
I was not knowing this, thanks for sharing
-
-
I followed their steps (y) anf it works
Thanks for sharing me information <3
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks