Skip to content

Commit ede9595

Browse files
committed
The default image version can be specified by dropping the width value
1 parent 29f5ab5 commit ede9595

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ npm install responsively-lazy
2323
bower install responsively-lazy
2424
```
2525

26-
The library does not have any dependencies and it's just 1.1kb gzipped and minified.
26+
The library does not have any dependencies, and it's just 1.1kb gzipped and minified.
2727

2828
## Usage
2929

@@ -51,7 +51,7 @@ You can list image versions in the [WebP format](https://en.wikipedia.org/wiki/W
5151

5252
## A new concept
5353

54-
Responsively Lazy is very different from the other lazy loading libraries. They make you break your HTML by removing the `src` attribute, or make you put tiny version there or make you use `<noscript>` to make your images appear in Google Images. The following code has worked for ages.
54+
Responsively Lazy is very different from the other lazy loading libraries. They make you break your HTML by removing the `src` attribute, or make you put tiny version there or make you use `<noscript>` to make your images appear in Google Images. The following code has worked for ages:
5555
```
5656
<img src="image.jpg" />
5757
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "responsively-lazy",
33
"title": "Responsively Lazy",
4-
"version": "1.1.0",
4+
"version": "1.2.0",
55
"description": "Lazy load responsive images",
66
"homepage": "http://ivopetkov.com/b/lazy-load-responsive-images/",
77
"author": {

responsivelyLazy.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,13 @@ if (typeof responsivelyLazy === 'undefined') {
3939
for (var j = 0; j < optionsCount; j++) {
4040
var option = options[j].trim();
4141
var spaceIndex = option.lastIndexOf(' ');
42-
var optionImage = option.substr(0, spaceIndex);
43-
var optionWidth = parseInt(option.substr(spaceIndex + 1, option.length - spaceIndex - 2), 10);
42+
if (spaceIndex === -1) {
43+
var optionImage = option;
44+
var optionWidth = 999998;
45+
} else {
46+
var optionImage = option.substr(0, spaceIndex);
47+
var optionWidth = parseInt(option.substr(spaceIndex + 1, option.length - spaceIndex - 2), 10);
48+
}
4449
var add = false;
4550
if (optionImage.indexOf('.webp', optionImage.length - 5) !== -1) {
4651
if (responsivelyLazy.hasWebPSupport) {

responsivelyLazy.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)