在使用带有LiipImagineBundle的流时,如何在模板中格式化图像标记

时间:2014-04-27 13:23:16

标签: symfony symfony-2.4 liipimaginebundle gaufrette

如果我将LiipImagineBundle配置为使用stream data loader,我如何制作图像标记以在模板中使用该数据加载器?

更新了配置

knp_gaufrette:
adapters:
    image_storage:
        amazon_s3:
            amazon_s3_id: namespace_admin.amazon_s3
            bucket_name:  %amazon_s3_bucket_name%
            create:       false
            options:
                create:     true
                directory: 'mydir'
                region:     %amazon_s3_region%


filesystems:
    image_storage:
        adapter:    image_storage
        alias:      image_storage_filesystem

    s3_storage:
        adapter:    image_storage

stream_wrapper:
        protocol: data
        filesystems:
            - s3_storage



namespace_admin:
    amazon_s3:
        aws_key:        %amazon_aws_key%
        aws_secret_key: %amazon_aws_secret_key%
        aws_region:     %amazon_s3_region%
        base_url:       %amazon_s3_base_url%

liip_imagine:
    loaders:
        stream.my_namespace_images:
            stream:
                wrapper: data://s3_storage

resolvers:
   default:
      web_path: ~

filter_sets:
    cache: ~
    gi_thumb:
        data_loader: stream.my_namespace_images
        quality: 75
        filters:
            thumbnail: { size: [120, 90], mode: outbound }

1 个答案:

答案 0 :(得分:0)

你需要做两件事。

  1. gi_thumb过滤器需要将data_loader设置为stream.get_inspired_images
  2. 在您的模板中,您只需在该加载程序可加载的文件路径上调用imagine_filter{{ '/example/path/image.png'|imagine_filter('gi_thumb', true) }}
  3. 这会加载此图片:http://your-bucket.s3.amazonaws.com/example/path/image.png