Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imagine_filter() not generating the correct url in LiipImagineBundle #360

Closed
mappedinn opened this issue Mar 22, 2014 · 12 comments
Closed

Comments

@mappedinn
Copy link

I think there is a bug in the bundle LiipImagineBundle. I explain:

Here is my new config of the bundle:

    liip_imagine:
        resolvers:
        default:
            web_path:  
                web_root: %kernel.root_dir%/../web/img
                # %kernel.root_dir%/../web/img is the folder where filtered images will be created!
                cache_prefix: media/cache
                # media/cache the prefix of folder where the cached images will be created

    filter_sets:
        cache: ~
        my_thumb:
            quality: 75
            filters:
              thumbnail: { size: [120, 90], mode: outbound }

This is the twig part for displaying the image:

{# This way the filtered image will not be created!#}
<img src="{{ 'img/test.jpg' | imagine_filter('my_thumb') }}" />

{# That way, the filted images will be created. asset() must be used. #}
<img src="{{ asset('img/test.jpg' | imagine_filter('my_thumb')) }}" />

The generated link of the image is not correct! In fact, the obtained link is:

http://localhost/media/cache/my_thumb/img/test.jpg

The expected correct link is:

http://localhost/tuto/web/img/media/cache/my_thumb/img/test.jpg

There is a missing part in the url: tuto/web/img . Is this a bug?

To avoid that problem, I did this:

<img src="{{ asset('img/test.jpg' | imagine_filter('my_thumb'))|replace({'media':'tuto/web/img/media'}) }}" />

I guess that playing with twig is not a good solution.

It is a bug in LiipImagineBundle? If not, please give the correct config for that bundle!

Thanks!

@makasim
Copy link
Collaborator

makasim commented Mar 22, 2014

try to change cache_prefix:

liip_imagine:
        resolvers:
        default:
            web_path:  
                cache_prefix:  tuto/web/img/media/cache

@mappedinn
Copy link
Author

@makasim Thank you very much for being helpful.

For the configuration you gave me, the generated url is:
http://localhost/tuto/web/img/media/cache/my_thumb/img/sejour-tunisie-300x226.jpg

But, I am expecting this url:
http://localhost/tuto/web/tuto/web/img/media/cache/my_thumb/img/sejour-tunisie-300x226.jpg

It is as usual: tuto/web/img is missing!

Any idea?

@makasim
Copy link
Collaborator

makasim commented Mar 22, 2014

@mappedinn /tuto/web twice? If so try to set cache prefix to: /tuto/web/tuto/web/img/media/cache

@mappedinn
Copy link
Author

yes!

@makasim
Copy link
Collaborator

makasim commented Mar 22, 2014

I've updated the comment above.

@mappedinn
Copy link
Author

which version you have for symfony, imagine/imagine and liip/imagine-bundle?

@makasim
Copy link
Collaborator

makasim commented Mar 22, 2014

symfony 2.3 and latest master of the bundle

@mappedinn
Copy link
Author

same as you!

Where you put you images? Are there in a sub folder of web folder?

@mappedinn
Copy link
Author

@makasim I have just tried set cache prefix to: /tuto/web/tuto/web/img/media/cache

The problem is still the same.

the generated url is:
http://localhost/tuto/web/tuto/web/img/media/cache/my_thumb/img/sejour-tunisie-300x226.jpg

The expected url is:
http://localhost/tuto/web/tuto/web/tuto/web/img/media/cache/my_thumb/img/sejour-tunisie-300x226.jpg

As usual, tuto/web/img is missing!

For any chosen cache_prefix, I have this:

{# this twig code never works! #}
<img src="{{ asset('img/sejour-tunisie-300x226.jpg'|imagine_filter('my_thumb')) }}" />

{# this twig code always works! #}
<img src="{{ asset('img/sejour-tunisie-300x226.jpg'|imagine_filter('my_thumb'))|replace({'media':'tuto/web/img/media'}) }}" />

@mappedinn
Copy link
Author

I switch back to "liip/imagine-bundle": "v0.21.1"

This version works correctly...

@leopro
Copy link

leopro commented Apr 18, 2014

Similar problem, same solution: I switched to 0.21.1
As I'll have some time to spend, I would like to help for debugging.

@cronk1986
Copy link

Hi,
I solve this issue with this:

liip_imagine :

resolvers :
    default :
        web_path :
            web_root: "%kernel.root_dir%/../web"
            cache_prefix: "media/cache"
loaders:
    default:
        filesystem:
            data_root: "%kernel.root_dir%/../web/uploads/images"
filter_sets:
    cache: ~
    thumblists:
        quality: 75
        filters:
            thumbnail  : { size : [199, 199], mode : outbound }

the key is data_root: "%kernel.root_dir%/../web/uploads/images" all images are in "/web/uploads/images" will be rendered directly with using < img src="{{ entity.mainImage | imagine_filter('thumblists') }}" >

I hope it works for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants