question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

<b-image src="/.svg">

See original GitHub issue

Hello. This is my issue: when my attribute src in my <b-img> appoint for a svg, the console says 404. But if i set some url for the src, this works well. If i try with <img>, the svg load too.

Didn’t work:

<b-img src="../assets/SVG/logo-home.svg" fluid alt="logo-home.svg">

Work:

<b-img src="http://verdao.net/imgs/noticias/moises_30_home.jpg" fluid alt="logo-home.svg"

Work:

<img src="../assets/SVG/logo-home.svg" alt="logo-home.svg">

I am using the Nuxt.js.

I try <b-img src="assets\Ativo2.png" alt="logo-home.svg"> now and not works too, no error, but not render.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
tmorehousecommented, Oct 25, 2017

If for some reason you cannot configure the vue-loader transformToRequire option, you can use the following webpack workaround:

<b-img :src="require('~/assets/img/picture.jpg')" />

Just make sure you use the v-bind syntax for src (i.e. add the : in front of src)

3reactions
nekdolancommented, Nov 15, 2017

@tmorehouse I have reinstalled my whole code an I noticed that the vueLoader I now have does not have the query attribute so I had to use the options attribute. See also: https://github.com/nuxt/nuxt.js/issues/956

{
  build: {   
    extend (config, ctx) {
      const vueLoader = config.module.rules.find((rule) => rule.loader === 'vue-loader')
      vueLoader.options.transformToRequire = {
        'img': 'src',
        'image': 'xlink:href',
        'b-img': 'src',
        'b-img-lazy': ['src', 'blank-src'],
        'b-card': 'img-src',
        'b-card-img': 'img-src',
        'b-carousel-slide': 'img-src',
        'b-embed': 'src'
      }
    }
  }
}

So it depends on the version, but I am not entirely sure which is which

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using SVG | CSS-Tricks
SVG is an image format for vector graphics. It literally means Scalable Vector Graphics. Basically, what you work with in Adobe Illustrator.
Read more >
Do I use <img>, <object>, or <embed> for SVG files?
In most circumstances, I recommend using the <object> tag to display SVG images. It feels a ...
Read more >
<image> - SVG: Scalable Vector Graphics - MDN Web Docs
The <image> SVG element includes images inside SVG documents. It can display raster image files or other SVG files. The only image formats ......
Read more >
How to Use SVG Images in CSS and HTML – A Tutorial for ...
SVG images can be written directly into the HTML document using the <svg> </svg> tag. To do this, open the SVG image in...
Read more >
The Best Way to Embed SVG on HTML (2021) - Vecta.io
Use <img> tag and embed fonts using Nano. If possible use static compression, and compress your SVG with Brotli for the smallest sizes....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found