fruitcake/magento2-custom-image-url

目录的 Magento2 自定义图片 URL

v0.1.1 2023-07-16 17:55 UTC

This package is auto-updated.

Last update: 2024-09-16 20:20:03 UTC


README

Magento 2.4 提供设置动态 URL 的选项(常规 -> 网络 -> URL 选项)。此模块添加了额外的选项来定义 URL 的格式。

安装

composer require fruitcake/magento2-custom-image-url
php bin/magento module:enable Fruitcake_CustomImageUrl
php bin/magento setup:upgrade

配置

您可以在“常规 -> 网络 -> URL 选项”中配置 URL。将“目录媒体 URL 格式”选项设置为“基于查询参数的图像优化”。这将防止 Magento 创建缩放图像。选择自定义 URL 格式以使用 Imgproxy 或模式来使用此模块。

image

模式

提供要替换 URL 的模式

示例 https://example.com/{{path}}?w={{width}}&h={{height}}

配置中描述了可用的过滤器(用于 urlencode 等)和变量。

Imgproxy

image

使用 Imgproxy 格式,无论是通过 URL、S3 还是本地文件。您可以提供密钥/哈希来签署 URL

这可以与 AWS 远程存储一起使用:https://devdocs.magento.com/guides/v2.4/config-guide/remote-storage/config-remote-storage-aws-s3.html

您可以提供主机和选项。格式将由模块生成。

不安全的代理映射 URL + 转换为 Webp

docker run -p 8080:8080 -e IMGPROXY_ENFORCE_WEBP=1 darthsim/imgproxy

示例 Docker 配置,使用 S3 + 签名进行代理

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

有关更多选项,请参阅 https://docs.imgproxy.net/

有关启用缓存的示例 nginx 代理配置,请参阅 imgproxy-nginx-cached.conf

待办事项/未来想法

  • 其他 CDNs
  • ..

许可证

MIT