Skip to content

Instantly share code, notes, and snippets.

@harikt
Last active November 29, 2016 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/7575141647d854e023f8d32a381998d1 to your computer and use it in GitHub Desktop.
Save harikt/7575141647d854e023f8d32a381998d1 to your computer and use it in GitHub Desktop.

Consider I have two domains.

  1. http://app.com/ => /home/app/web
  2. https://images.app.com/ => /home/images/directory/

There is a form in app.com which can upload images to /home/images/directory .

The question is : Is there a way that the bundle can generate the image on the /home/images/directory/ or do we need to write our own cache resolvers ?

I have tried flysystem resolver .

Eg : Consider image is located at /home/app/web/a42e93fb7d08c90a160da87a5dc91028.png and inside twig we can use

<img src="{{ 'a42e93fb7d08c90a160da87a5dc91028.png' | imagine_filter('my_thumb') }}" />

This actually creates a url as : http://images.app.com/media/cache/my_thumb/a42e93fb7d08c90a160da87a5dc91028.png

But this will not create image in /home/images/directory/media/cache/my_thumb/a42e93fb7d08c90a160da87a5dc91028.png

bin/console liip:imagine:cache:resolve ../data/img/product/a42e93fb7d08c90a160da87a5dc91028.png --filters=my_thumb

throws source path is outside the defined root path.

[Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException]                                                            
  Source image was searched with '../data/img/product/a42e93fb7d08c90a160da87a5dc91028.png' out side of the defined root path

I have found this is where that cause trouble.

The config.yml is as

//app/config.yml

liip_imagine:    
    resolvers:
        product_images:
            flysystem:
                filesystem_service: oneup_flysystem.product_images_filesystem
                root_url:           "http://img-loc.app.com/"
                cache_prefix:       media/cache
                # visibility:         public        
        default:            
            web_path: ~
    # your filter sets are defined here
    filter_sets:        
        cache: ~
        # the name of the "filter set"
        my_thumb:
            cache: product_images            
            quality: 75            
            filters:
                thumbnail: { size: [120, 90], mode: outbound }                

oneup_flysystem:
    adapters:
        product_images:
            local:
                directory:  '%kernel.root_dir%/../../data/img/product'

    filesystems:
        product_images:
            adapter: product_images           

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment