2

I can't get LiipImagineBundle to recognize stream paths. Instead of loading the image and applying the specified filter set, it just takes the stream path and treats it as if it were a normal web path.

This is the configuration that I was able to piece together from various sources. I couldn't find any addressing this issue exactly. The settings don't appear to have achieved anything at all as far as LiipImagineBundle is concerned. No errors or warnings are thrown and there's nothing in the logs. It's completely ignoring my configuration.

#/src/Acme/StorageBundle/Resources/config/services.yml
services:
  acme_storage.amazon_s3:
    class:        %acme_storage.amazon_s3.class%
    arguments:
      options:
        key:      %acme_storage.amazon_s3.aws_key%
        secret:   %acme_storage.amazon_s3.aws_secret_key%
        certificate_authority: true

  liip_imagine.binary.loader.stream.amazon_s3:
    class: %liip_imagine.binary.loader.stream.class%
    arguments:
      - @liip_imagine
      - 'gaufrette://amazon_s3/'
    tags:
      - name:   liip_imagine.binary.loader
        loader: stream.amazon_s3

  liip_imagine.cache.resolver.amazon_s3:
    class: Liip\ImagineBundle\Imagine\Cache\Resolver\AmazonS3Resolver
    arguments:
      - @acme_storage.amazon_s3
      - %amazon_s3_bucket_name%
    tags:
      - name: liip_imagine.cache.resolver
        resolver: cache.amazon_s3

# /app/config/config.yml
knp_gaufrette:
  stream_wrapper:
    protocol:     gaufrette
    filesystems:
      amazon_s3:  photo_storage
  adapters:
    photo_storage:
      amazon_s3:
        amazon_s3_id: beebop_storage.amazon_s3
        bucket_name:  %amazon_s3_bucket_name%
        create:       false
        options:
          create:     true
          region:     %amazon_s3_region%
  filesystems:
    photo_storage:
      adapter:        photo_storage
      alias:          photo_storage_filesystem

liip_imagine:
  cache:              cache.amazon_s3
  loaders:
    stream.amazon_s3:
      stream:
        wrapper:      gaufrette://amazon_s3

  filter_sets:
    cache: ~
    event_small:
      data_loader:    stream.amazon_s3
      quality:        75
      filters:
        thumbnail:
          size:       [60, 60]
          mode:       outbound
          allow_upscale: true

Twig:

{{ 'gaufrette://amazon_s3/file.jpg'|imagine_filter('event_small') }}

Produces:

http://example.com/media/cache/resolve/event_small/gaufrette://amazon_s3/file.jpg
tvanc
  • 3,807
  • 3
  • 25
  • 40

1 Answers1

0

I did just that weeks ago, but I didn't use s3 for the cache. Your problems seem to be with the image path. Try this on twig:

{{ 'file.jpg'|imagine_filter('event_small') }}

Since your data loader knows what stream you're using, the cache resolver knows the URL the file is located at, then you just need to pass the file name.

Another thing that differs from your config to mine, is that mine has a leading / on the gaufrette path:

liip_imagine:
  loaders:
    stream.amazon_s3:
      stream:
        wrapper:      gaufrette://amazon_s3/

Hope it can help.

lsouza
  • 2,448
  • 4
  • 26
  • 39
  • Unfortunately after applying those changes the behavior of LiipImagineBundle remains unchanged. It just takes whatever I pass into `imagine_filter()` and prepends a local cache path to it. – tvanc Sep 26 '14 at 19:50
  • When you open `http://example.com/media/cache/resolve/event_small/file.jpg` on the browser, do you get any error? This path is supposed to redirect you to the cached file. – lsouza Sep 27 '14 at 01:54
  • Yes, I get a 500 internal server error: "The given context is no valid resource," occurring in `Liip\ImagineBundle\Binary\Loader\StreamLoader`. I may be able to figure it out by looking deeper into what's going on at that location. – tvanc Sep 27 '14 at 02:47