Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback option in case of missing images #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ h3. elPosition (only when not used on the body)

This is the css position given to the containing element when used on anything except the body. (type=String, default=relative)

h4. fallback

This is the path of a fallback image to be loaded if the original image is missing or doesn't load.

h2. Setup

Include the jQuery library and Anystretch plugin files in your webpage (preferably at the bottom of the page, before the closing BODY tag):
Expand Down Expand Up @@ -61,6 +65,10 @@ If you require Anystretch to work on one or more elements inside the page, rathe

h2. Changelog

h3. Version 1.1.1

* Added the fallback option.

h3. Version 1.1

* Changed options from centeredX/centeredY to positionX/positionY to allow for greater control
Expand Down
6 changes: 5 additions & 1 deletion jquery.anystretch.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@

// Attach the settings
container.data("settings", settings);


img.one('error', function() {
$(this).attr("src", settings.fallback);
});

img.attr("src", src); // Hack for IE img onload event

// Adjust the background size when the window is resized or orientation has changed (iOS)
Expand Down
2 changes: 1 addition & 1 deletion jquery.anystretch.min.js

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