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