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.

[Feature Request] v-img fallback support

See original GitHub issue

Problem to solve

As the web progresses forward, new standards of image compression arise. Since not all browsers support the latest formats, we need an effective way to provide a fallback format when the passed media cannot be rendered.

Currently v-img will not render the background-image if the provided image format is not supported.

Ex. This example renders in Chrome 70, but not in Firefox 63.

<v-img src="img/awesomeWebPImage.webp" />

Before using Vuetify I solved this problem with the HTML5 <picture> element. I would love to do the same with v-img!

<picture>
  <source srcset="img/awesomeWebPImage.webp" type="image/webp">
  <source srcset="img/creakyOldJPEG.jpg" type="image/jpeg"> 
  <img src="img/creakyOldJPEG.jpg" alt="Alt Text!">
</picture>

Proposed solution

As a developer using v-img, the easiest approach for myself is allowing src prop to contain an array of image sources. When an array of sources is passed the browser could fallback in the order of sources provided.

Therefore the snippet from above would become:

<v-img :src="['img/awesomeWebPImage.webp', 'img/creakyOldJPEG.jpg']" />

This would be the resulting css:

.img {
  background-image: image("img/awesomeWebPImage.webp", "img/creakyOldJPEG.jpg")
}

Source: https://codepen.io/sandip_rb/pen/ZWNEwr

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:47
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
esynapscommented, Jan 26, 2020

Any update ?

1reaction
johnleidercommented, Oct 13, 2021

As far as I can understand from this thread, this feature will only be available in Vuetify 3 and not be added to Vuetify 2?

That is correct.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide to SVG Fallbacks - CSS-Tricks
SVGInjector is a JavaScript library that can help with <img> fallbacks in specific scenarios. It's main purpose is to replace <img> with inline ......
Read more >
Feature Request – fallback image for AB Post Grid
Hello again-. Would be awesome if there was a setting for 'default featured image' that could display when no featured image set, on...
Read more >
324764 - Implement MathML text and image fallback - chromium
Here is a testcase with some CSS rules to consider the semantics annotations and the alttext attribute. The altimg seems a bit more...
Read more >
Using <picture> Tag with X Theme for webp and jpg fallback
Hello, I can't find something about that in your manual. Is it possible to use the < picture > Tag with X to...
Read more >
Placeholders & fallbacks - amp.dev
In the spirit of perceived performance and progressive enhancement, ... <div fallback> <p>This browser does not support the video element.
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