Coder Social home page Coder Social logo

Comments (5)

quantizor avatar quantizor commented on July 18, 2024

If you left the default src empty, you could do something like this..

img.image[src=""] {
  background-image: url("your-placeholder.jpg");
}

Then when the src attribute is filled in by Unveil, the placeholder's properties are removed.

from unveil.

luis-almeida avatar luis-almeida commented on July 18, 2024

I think nothing needs to be changed to allow this. You can add the classes you want to your images. Unveil doesn't care about that.
I would advise you not to leave images without a src since it's not valid and you'll be getting a bunch of errors in your console. Also some browsers will probably show the "missing image" thumbnail and it's gonna look pretty bad, firefox even renders the alt text (if you set it) as a link.

But there are workarounds. I haven't tested it but in these thread there seems to be some valid options:
http://stackoverflow.com/questions/5775469/whats-the-valid-way-to-include-an-image-with-no-src

If it works than you could do:

img.image[src="//:0"] {
  background-image: url("your-placeholder.jpg");
}

(not tested)

from unveil.

universaldenmark avatar universaldenmark commented on July 18, 2024

You're right that actually works. But I would like to make different classes for different placeholders. How would that be possible?

from unveil.

luis-almeida avatar luis-almeida commented on July 18, 2024

HTML:

<img class="image-1" src="//:0">
<img class="image-2" src="//:0">
<img class="image-3" src="//:0">

CSS:

.image-1[src="//:0"] {
  background-image: url("your-placeholder-1.jpg");
}
.image-2[src="//:0"] {
  background-image: url("your-placeholder-2.jpg");
}
.image-3[src="//:0"] {
  background-image: url("your-placeholder-3.jpg");
}

JS:

$(".image-1, .image-2, .image-3").unveil()

Not tested but that should work.

from unveil.

luis-almeida avatar luis-almeida commented on July 18, 2024

I'm closing this issue as it doesn't seem to be valid anymore.
Let me know if otherwise.

from unveil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.