Media url in multilingual site

Hello,

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 }}{{ page.media.images|first.url(true) }}" />

It gives me for example:
http://nimon.org/fr/user/pages/35.axismvndi/axis1.jpg
instead of:
http://nimon.org/user/pages/35.axismvndi/axis1.jpg

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

Nicolas

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

@nix

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

  • Next to the page as you do now.
    page.media.images|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 http://nimon.org manually.

Hope this helps.