networkteam / image-proxy
使用imgproxy服务Neos图片和缩略图,imgproxy是一个快速可扩展的图像处理微服务
1.2.1
2024-09-18 12:33 UTC
Requires
- neos/neos: ^4.0 || ^5.0 || ^7.0 || ^8.0
Requires (Dev)
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
README
使用imgproxy服务Neos图片和缩略图,imgproxy是一个快速可扩展的图像处理微服务
安装
通过Composer安装包
composer require networkteam/image-proxy
为您的imgproxy实例添加设置
cat <<EOF > Configuration/Settings.ImageProxy.yaml Networkteam: ImageProxy: # The imgproxy base URL imgproxyUrl: 'http://localhost:8080' # An example key ('secret') key: '736563726574' # An example salt ('hello') salt: '68656C6C6F' EOF
如果您没有为imgproxy设置密钥和盐,请留空密钥和盐(不要在生产环境中这样做)。
注意:URL应该是公开可访问的。
注意:当一切正常时,可以使用./flow media:clearthumbnails
命令删除先前生成的缩略图。它们不再使用。
通过Docker运行imgproxy
从S3提供服务
docker run -p 8080:8080 -it \ -e IMGPROXY_USE_S3=true \ -e IMGPROXY_S3_ENDPOINT=https://your-minio-or-s3-endpoint.tld \ -e AWS_ACCESS_KEY_ID=your-access-key \ -e AWS_SECRET_ACCESS_KEY=your-secret-key \ -e IMGPROXY_KEY=736563726574 \ -e IMGPROXY_SALT=68656C6C6F \ darthsim/imgproxy
它是如何工作的?
- 通过AOP拦截所有对
AssetService->getThumbnailUriAndSizeForAsset()
的调用。 - 如果请求的资产是图像,将生成包含相应处理指令的imgproxy URL。
- 如果使用S3存储,方面将自动生成imgproxy源的
s3://
URL,否则将使用原始资产资源的公开URL作为源。 - Neos不会生成任何缩略图,它们将根据客户端的请求由imgproxy即时生成。
注意:确保在imgproxy之上添加缓存代理/CDN,它没有内置的缓存!