Comments (1)
Hi @pmathbliss
Functionality to resize product images was not added out of the box because Magento already resizes those images. However, if you need that, you can use the following code in your custom Block:
public function getImageUrl(int $width, int $height) : string
{
$customAttribute = $this->getProduct()->getCustomAttribute('image');
if (!$customAttribute) {
return '';
}
$imageFilename = $customAttribute->getValue();
if (!$imageFilename) {
return '';
}
$imagePath = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
. 'catalog'
. DIRECTORY_SEPARATOR
. 'product'
. $imageFilename;
/** @var \Staempfli\ImageResizer\Model\Resizer $imageResizer */
$imageResizer = $this->getImageResizer();
return $imageResizer->resizeAndGetUrl($imagePath, $width, $height);
}
If you would like to have that functionality to resize product images by default, you can open a Pull Request with your suggested code. Let me know if you need help with that.
from magento2-module-image-resizer.
Related Issues (15)
- Feature Request: Add Adaptive Resizing HOT 3
- Feature request: Add more methods to the interface HOT 1
- Directory separator incorrectly used for URL in getResizedImageUrl() HOT 3
- Feature request: Set Image Compression
- Original Image is used when using CDN HOT 2
- does not support theme images HOT 4
- Add support for php 7.2 HOT 2
- fopen with url error HOT 3
- Watermark in images
- isAnimatedGif fails on local domain
- Feature request: CMS syntax support
- Set backgroundColor image HOT 2
- initRelativeFilenameFromUrl doesn't take into account cdn url HOT 2
- Feature Request: Widget HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magento2-module-image-resizer.