Media url in multilingual site


I have a problem accessing the url of the first image to define twitter card image. I have a multilingual site (en + fr). When I do:
<meta name="twitter:image" property="twitter:image" content="{{ base_url_absolute }}{{|first.url(true) }}" />

It gives me for example:
instead of:

There is the ‘fr’ code in the url. How can I have the right url?
Thanks in advance,


The language suffix was actually in base_url_absolute so I hardcoded the base url.


You have a few options as to where to store and how to fetch your images:

  • Next to the page as you do now.|first.url will return /user/pages/35.axismvndi/first-image.jpg.
  • You could place all images together in user/pages/images.
    See Where to put your media files
    • page.find('/images').media.images|first.url will return /user/pages/images/first-image.jpg.
    • page.find('/images').media['image.jpg'].url will return /user/pages/images/image.jpg
    • media_directory('page://images').images|first.url will return /user/pages/images/first-image.jpg
  • Or you could place all media in user/themes/mytheme/images:
    media_directory('theme://images').images|first.url will return /user/themes/my-theme/images/axis1.jpg
    See Media Directory

All options will return a url starting with /user/pages/... or /user/themes/... which will be translated to the correct url in the browser. No need to add manually.

Hope this helps.