我在Symfony2上使用LiipImagineBundle并试图整合
使用gaufrette来捕捉amazonS3上的图像,但我在图像上的“src”是错误的。
我不知道错误是不是我的配置......
这个树枝代码:
{{ '123.jpg' | imagine_filter('128_128_75_s3') }}
// return http://localhost/project/web/media/cache/resolve/128_128_75_s3/123.jpg
// expected is http://bucket.s3.amazonaws.com/media/cache/resolve/128_128_75_s3/123.jpg
我的sevices.yml:
services:
amazonS3:
class: AmazonS3
arguments:
options:
key: %aws_key%
secret: %aws_secret%
liip_imagine.cache.resolver.amazon_s3:
class: Liip\ImagineBundle\Imagine\Cache\Resolver\AmazonS3Resolver
arguments:
- "@amazonS3"
- "%aws_bucket%"
tags:
- { name: 'liip_imagine.cache.resolver', resolver: 'resolver.amazon' }
liip_imagine.binary.loader.stream.import:
class: Liip\ImagineBundle\Binary\Loader\StreamLoader
arguments:
- 'gaufrette://import/'
tags:
- { name: 'liip_imagine.binary.loader', loader: 'import' }
我的config.yml:
# Gaufrette media bundle
knp_gaufrette:
adapters:
import:
amazon_s3:
amazon_s3_id: amazonS3
bucket_name: %aws_bucket%
options:
create: true
filesystems:
import:
adapter: import
alias: import
stream_wrapper: ~
#Liip Imagine Bundle
liip_imagine:
cache: resolver.amazon
data_loader: stream.import
filter_sets:
128_128_75_s3:
quality: 75
filters:
thumbnail: { size: [128, 128], mode: outbound }
答案 0 :(得分:2)
不推荐使用AmazonS3Resolver,尝试使用AwsS3Resolver:
#service.yml
awsS3:
class: Aws\S3\S3Client
factory_class: Aws\S3\S3Client
factory_method: factory
arguments:
-
key: %aws_key%
secret: %aws_secret%
region: %aws_region%
liip_imagine.cache.resolver.amazon_s3:
class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
arguments:
- "@awsS3"
- %aws_bucket%
tags:
- {name: 'liip_imagine.cache.resolver', resolver: 'resolver_as3'}
#config.yml
liip_imagine:
cache: resolver_as3
data_loader: import
filter_sets:
128_128_75_s3:
quality: 75
filters:
thumbnail: { size: [128, 128], mode: outbound }