Search code examples
phpfacebooksymfonytwigfosfacebookbundle

Twig template external url img


I am trying to display image from facebook profile.

routing.yml

_graph_facebook:
path: graph.facebook.com/{fbId}/{var}
requirements:
    _scheme:  https

template.html.twig

What I get is htpps://mydomain.local/graph.facebook.com/facebookId/picture .

I was trying with assets but it works only if it's hardcoded.

{% image 'https://graph.facebook.com/'~app.user.facebookId~'/picture'%}
        <img src="{{ asset_url }}" alt="Example" />
{% endimage %}

This code doesn't work it says that: Unexpected token "operator" of value "~". I couldn't find answer probably it's vaery simply.Thanks for Your help


Solution

  • As said in the comments, the router only applies to the URLs of your website.

    Anyway, you can simply display the image with the facebookId value:

    <img src="https://graph.facebook.com/{{ app.user.facebookId }}/picture" alt="Example" />