Skip to content

Commit

Permalink
Merge pull request #5 from janrembold/preload
Browse files Browse the repository at this point in the history
Added preload and auto dpr support
  • Loading branch information
janrembold committed Jan 28, 2016
2 parents fb3a1a8 + f37c2a2 commit 3445428
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 44 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Just load image by sizes you really need, save lots of bandwidth and make the wo

This plugin doesn't need any matchMedia polyfills or shims for unknown html elements.

Minified size is 2.58KB | gzipped: 1.66KB

## Usage

Expand Down Expand Up @@ -76,6 +75,7 @@ Setting this parameter is recommended because it optimizes the target size for t

This is the resize event used to detect the resize of the viewport.
You can set any event that can be used inside jQuery's `.on()` function.
Set `resizeEvent` to empty string to disable image calculation on resize.

It defaults to the `resize` event, which is not recommended because of the high amount of fired events.

Expand All @@ -99,6 +99,15 @@ If you want to show only Retina images set this value to `2`
#### `attributes` (default: `['title', 'alt', 'class', 'width', 'height']`)

These attributes are set to the generated responsive image tag. See Attributes-Section below for detailed information.

#### `preload` (default: `false`)

Preload images before loading them into the DOM. Default is immediate loading of images.

#### `autoDpr` (default: `false`)

Automatically include dpr on best fit width calculation.
If enabled this adds retina support by default without the need for data-min-dpr attributes.

#### `onGetWidth` (default: `null`)

Expand Down
2 changes: 1 addition & 1 deletion build/jquery.responsiveImage.map

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

6 changes: 3 additions & 3 deletions build/jquery.responsiveImage.min.js

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

3 changes: 2 additions & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ <h4>Unsorted sources (same as retina demo)</h4>
$(document).ready(function () {
// init responsive images
$('.picture').responsiveImage({
resizeEvent: 'debouncedwidth'
resizeEvent: 'debouncedwidth',
preload: true
});

// load helpers
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-responsive-image",
"version": "1.2.1",
"version": "1.3.0",
"description": "A jQuery responsive image plugin with viewport or container based width matching support",
"author": "Jan Rembold <[email protected]>",
"main": "build/jquery.responsiveImage.min.js",
Expand Down
Loading

0 comments on commit 3445428

Please sign in to comment.