Skip to content

Add option srcAttribute#1

Open
emri99 wants to merge 1 commit intomasterfrom
emri99-setting-srcAttribute
Open

Add option srcAttribute#1
emri99 wants to merge 1 commit intomasterfrom
emri99-setting-srcAttribute

Conversation

@emri99
Copy link
Owner

@emri99 emri99 commented Nov 4, 2016

Allow to define the element attribute to get image url from.

This can be used to preload images used as CSS background:

<style>
.preload-me {
  background-image: url('path/to/loader.gif');
  background-repeat: no-repeat;
  background-size: contain;
} 
</style>
<div class="preload-me" data-image="/image/to/load.png"></div
$('.preload-me').preload({
  srcAttribute: 'data-image',
  onComplete: function(data) {
    if (data.found) {
       data.original.style.backgroundImage = 'url('+data.image+')';
    }
  }
});

Allow to define the element attribute to get image url from.

This can be used to preload images used as CSS background:

````
<style>
.preload-me {
  background-image: url('path/to/loader.gif');
  background-repeat: no-repeat;
  background-size: contain;
} 
</style>
<div class="preload-me" data-image="/image/to/load.png"></div
````

````
$('.preload-me').preload({
  srcAttribute: 'data-image',
  onComplete: function(data) {
    if (data.found) {
       data.original.style.backgroundImage = 'url('+data.image+')';
    }
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant