Symfony2 LiipImagineBundle path cache probleme

2019-08-04 10:25发布

I've setup a LiipImagineBundle configuration on a linux computer (xubuntu 14.10) :

routing.yml

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

config.yml

liip_imagine:
    resolvers:
       default:
          web_path: ~

    filter_sets:
        cache: ~
        dashboard_thumb:
            quality: 75
            filters:
                thumbnail: { size: [60, 60], mode: outbound }

and in my twig template :

<img src="{{ asset(company.logo.getPath) | imagine_filter('dashboard_thumb') }}">

All sources images are under web/uploads path This was working fine, image thumbnails are generated under web/media/cache/dashboard_thumb/uploads/

My source files are stored under an USB stick, and i lanch server with server:run commande (so under 127.0.0.1:8000)

But recently, i lanched the server under another computer (linux mint 17) and then, image cache are not generated anymore.

when i look at the generated html source, file path for images are :

http://127.0.0.1:8000/media/cache/resolve/dashboard_thumb/uploads/myimage.png

so i dont know why there is a 'resolve' in the path

Other thing, if i launch the command :

liip:imagine:cache:resolve uploads/myimage.png

the path and image web/media/cache/dashboard_thumb/uploads/myimage.png are well created

why this doesnt work automatically?

Thanks.

2条回答
够拽才男人
2楼-- · 2019-08-04 10:53

... so i dont know why there is a 'resolve' in the path

If You do not have a cache for your image, LiipImagineBundle (imagine_filter in your case) generates a route according this rule

liip_imagine_filter:
    path: /media/cache/resolve/{filter}/{path}
    defaults:
        _controller: '%liip_imagine.controller.filter_action%'
    methods:
        - GET
    requirements:
        filter: '[A-z0-9_-]*'
        path: .+

, and your request handles by ImagineController https://github.com/liip/LiipImagineBundle/blob/1.0/Controller/ImagineController.php

So, You see not image path, but route. Controller generates the cache and your second request to this image will give you actually path to image.

There is a problem, if your need to attach image to mail message, You have to resolve image before attaching this one.

Also if cache not generates anymore, the problem maybe in your web server configuration. Imagine that Your Nginx decides that web/media/cache/* is static content, so, the route web/media/cache/resolve just not working.

查看更多
来,给爷笑一个
3楼-- · 2019-08-04 11:09

Seem a problem about Setting up Permissions. Basically the System operating users for the CLI(and deploy) and the web server must be on the same group.

Check the doc for Symfony Application Configuration and Setup

PS: the command you are looking for is chown but is only a workaround an i suggest you to fix to operating user layer.

Hope this help

查看更多
登录 后发表回答