Skip to content

Latest commit

 

History

History
61 lines (33 loc) · 1.96 KB

README.md

File metadata and controls

61 lines (33 loc) · 1.96 KB

Magento2 Custom Image Url

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.

image

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

image

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