Symfony2 LiipImagineBundle path cache probleme

安稳与你 提交于 2019-12-13 18:29:51

问题


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.


回答1:


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




回答2:


... 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.



来源:https://stackoverflow.com/questions/28252279/symfony2-liipimaginebundle-path-cache-probleme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!