Vue-meta: [QUESTION] How to load webpacked images in assets folder in vue meta?

Created on 11 Jul 2018  路  6Comments  路  Source: nuxt/vue-meta

Hi,
how do i load my images in /assets folder with vue-meta?

{ hid: 'og:image', name: 'og:image', content: require('~/assets/img/home/bri-booklet.jpg') },

doesn't seem to work. Any help?

question

Most helpful comment

Hi @dysol,

In the script tag, you could
import ogImage from "./assets/img/home/bri-booklet.jpg"

and then use it as below
{ hid: 'og:image', name: 'og:image', content: "https://your.domain" + ogImage}

All 6 comments

You don't need to load images in meta tags, bud
All you need is url path.

@canyoudev i meant webpacked images. Not static images where i can just state the /path/to/img

Hi @dysol,

In the script tag, you could
import ogImage from "./assets/img/home/bri-booklet.jpg"

and then use it as below
{ hid: 'og:image', name: 'og:image', content: "https://your.domain" + ogImage}

try again using functions and return your require('~/assets/img/home/bri-booklet.jpg')

Sorry, what I have said above didn't work... I've tried using base64 image, but I'm still looking for better approaches.

Just tried with one of the examples and @oahccc solution seems to work just fine (with file-loader configured in the webpack config for image files). That might very well be due to webpack updates since this issue was originally posted, but closing it for now. Please reopen or create a new issue with a reproduction if a problem still exists

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hvalcourtSerdy picture hvalcourtSerdy  路  3Comments

derz picture derz  路  3Comments

vishr picture vishr  路  5Comments

o-alexandrov picture o-alexandrov  路  5Comments

terazus picture terazus  路  8Comments