Type
magento2-module
Magento 2 Module to add simple image resizing capabilities in all blocks and .phtml templates
magento2-module
OSL-3.0, AFL-3.0
None
None
None
None
None
Magento 2 Module to add simple image resizing capabilities in all blocks and .phtml templates
$ composer require "staempfli/magento2-module-image-resizer":"~2.0"
imageResizer
is automatically available in all frontend Blocks.
You can resize your images just calling a method:
/** @var \Staempfli\ImageResizer\Model\Resizer $imageResizer */
$imageResizer = $block->getImageResizer();
$resizedImageUrl = $imageResizer->resizeAndGetUrl(<originalImageUrl>, $width, $height, [$resizeSettings]);
You can do that directly on the .phtml or in your custom Block.
Resized images are saved in cache to improve performance. That way, if an image was already resized, we just use the one in cache.
If you need to, you can clear the resized images cache on the Admin Cache Management