Skip to content

Commit

Permalink
The default image version can be specified by dropping the width value
Browse files Browse the repository at this point in the history
  • Loading branch information
ivopetkov committed Sep 1, 2015
1 parent 29f5ab5 commit ede9595
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ npm install responsively-lazy
bower install responsively-lazy
```

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

## Usage

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

## A new concept

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.
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:
```
<img src="image.jpg" />
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "responsively-lazy",
"title": "Responsively Lazy",
"version": "1.1.0",
"version": "1.2.0",
"description": "Lazy load responsive images",
"homepage": "http://ivopetkov.com/b/lazy-load-responsive-images/",
"author": {
Expand Down
9 changes: 7 additions & 2 deletions responsivelyLazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ if (typeof responsivelyLazy === 'undefined') {
for (var j = 0; j < optionsCount; j++) {
var option = options[j].trim();
var spaceIndex = option.lastIndexOf(' ');
var optionImage = option.substr(0, spaceIndex);
var optionWidth = parseInt(option.substr(spaceIndex + 1, option.length - spaceIndex - 2), 10);
if (spaceIndex === -1) {
var optionImage = option;
var optionWidth = 999998;
} else {
var optionImage = option.substr(0, spaceIndex);
var optionWidth = parseInt(option.substr(spaceIndex + 1, option.length - spaceIndex - 2), 10);
}
var add = false;
if (optionImage.indexOf('.webp', optionImage.length - 5) !== -1) {
if (responsivelyLazy.hasWebPSupport) {
Expand Down
10 changes: 5 additions & 5 deletions responsivelyLazy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ede9595

Please sign in to comment.