fruitcake / magento2-custom-image-url
Magento2 Custom Image URLS for the catalog
Installs: 6 999
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 4
Forks: 6
Open Issues: 0
Type:magento2-module
Requires
- php: ^7|~8.1.0
This package is auto-updated.
Last update: 2024-12-16 20:49:22 UTC
README
Magento 2.4 has the option to set a dynamic URL (General -> Web -> Url options). This module adds an extra option to define the format of the URL.
Install
composer require fruitcake/magento2-custom-image-url
php bin/magento module:enable Fruitcake_CustomImageUrl
php bin/magento setup:upgrade
Configuration
You can configure the url in General -> Web -> Url Options. Set the 'Catalog media URL format' option to 'Image optimization based on query parameters'. This will prevent Magento from creating resized images. Select a Custom URL format for Imgproxy or Pattern, to use this module.
Pattern
Provide a pattern to replace the URL with:
Example https://example.com/{{path}}?w={{width}}&h={{height}}
The available filters (for urlencode etc) and variables are described in the config.
Imgproxy
Use the Imgproxy format, either with URL, S3 or Local files. You can provide a key/hash to sign the URLs
This can be used with the AWS Remote storage: https://devdocs.magento.com/guides/v2.4/config-guide/remote-storage/config-remote-storage-aws-s3.html
You can provide the host and options. The format will be generated by the module.
Inscecure proxy to map the URL + Convert to Webp:
docker run -p 8080:8080 -e IMGPROXY_ENFORCE_WEBP=1 darthsim/imgproxy
Example Docker config to proxy with S3 + Signature
docker run -p 8080:8080 -e IMGPROXY_USE_S3=1 -e AWS_ACCESS_KEY_ID=accesskey -e IMGPROXY_S3_REGION=eu-central-1 -e AWS_SECRET_ACCESS_KEY="secret" -e IMGPROXY_KEY=key -e IMGPROXY_SALT=salt darthsim/imgproxy
See https://docs.imgproxy.net/ for more options.
See imgproxy-nginx-cached.conf for an example nginx proxy config with caching enabled.
Todo / future ideas
- Other CDNs
- ..
License
MIT