Comments (5)
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.
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.
You're right that actually works. But I would like to make different classes for different placeholders. How would that be possible?
from unveil.
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.
I'm closing this issue as it doesn't seem to be valid anymore.
Let me know if otherwise.
from unveil.
Related Issues (20)
- jQuery 1.8+ : Update doc for the callback example HOT 1
- the same img won't cached ?
- loading images using CSS class
- On/Off Unveil
- How to check if all images are loaded HOT 1
- Is it possible to use unveil.js for horizontal scrolling? HOT 1
- Spinner + Ease-in transition
- Fix for scrolling fast to the bottom of the page
- $(this).load(function() HOT 2
- Demo img broken HOT 1
- content reloading issue with iPhone6 and iPhone6 Plus
- When refreshing from halfway down page, unveil doesn't reveal unless page is scrolled up HOT 2
- Non Body Scroll doesn't load. HOT 4
- Question: svg image tags
- [Bug] Unveil.js remove http or https from url HOT 1
- sometimes the images aren't loaded and browser shows error icon until the page is scrolled HOT 4
- Picture element + different formats HOT 1
- How to use unveil with background images in the div with style tags?
- https://www.google.com/search?client=safari&hl=en-US&sxsrf=AOaemvIGDwXYs7FLguEK26G0s1p0xiRvQw:1637725269722&q=%3Cscript%3E+var+myrawlazy+%3D+new+lazy+loading();+of+(!myrawlazy.supports+observer+%26%26+typeof+jquery+!%3D%3D+%27undefined%27+%26%26+typeof+jquery(document).ready+%3D%3D%3D+%27function%27)+%7B+jquery(document).ready(function+()&spell=1&sa=X&ved=2ahUKEwjzlsOHirD0AhXWHDQIHdBEDbsQBSgAegQIARAF&biw=375&bih=553&dpr=2
- Hello/world
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unveil.