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.

Add class selector to b-avatar img tag for custom images in default slot instead of using element selector

See original GitHub issue

Is your feature request related to a problem? Please describe…

We need to override b-avatar’s img tag to add a loading="lazy". Unfortunately, the img css in bootstrap-vue uses an element selector as .b-avatar-img img rather than a unique class for the image tag, so we have to duplicate the css code.

Describe the solution you’d like

It would be preferable for it to be a class selector rather than an element selector. Then we could override the image exactly how it works in bootstrap-vue.

  <b-avatar ...>
    <template v-if="src" #default>
      <img :src="src" class="copied-from-b-avatar-img"> <!-- current -->
      <img :src="src" class="b-avatar-img-element"> <!-- preferred  -->
    </template>

Describe alternatives you’ve considered

We currently have to copy the code from .b-avatar-img img to our system, which isn’t ideal or future proof.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Hiwscommented, Nov 10, 2020

You could just wrap the <img> in a <span> with the class b-avatar-img. Should give the same result, except that there’ll be an additional span in the DOM.

<b-avatar>
  <template v-if="src" #default>
    <span class="b-avatar-img">
      <img loading="lazy" :src="src">
    </span>
  </template>
</b-avatar>
0reactions
stale[bot]commented, Apr 27, 2022

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Select a specific img tag in li tag - css - Stack Overflow
Your CSS selector selects all img-tags, that are directly a child of an a-tag inside your #menu-item-4. try this: #menu-item-4 > a img ......
Read more >
slotted() - CSS: Cascading Style Sheets - MDN Web Docs
The ::slotted() CSS pseudo-element represents any element that has been placed into a slot inside an HTML template (see Using templates and ...
Read more >
ion-img Tag - Ionic Framework
Img is a tag that will lazily load an image whenever the tag is in the viewport. This is extremely useful when generating...
Read more >
Picture perfect images with the modern <img> element
To place an image on a web page, we use the <img> element. ... set of images the browser can select from, as...
Read more >
Image component — Vuetify
v-img component is used to display a responsive image with lazy-load ... gradients should be written as a class on the content slot...
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