Skip to content

Commit

Permalink
Added Fallback for when requests fail. Useful for testing app in brow…
Browse files Browse the repository at this point in the history
…ser where image requests fail due to lack of CORS header.
  • Loading branch information
wei committed Jul 3, 2016
1 parent 619b36c commit 5ac8575
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion imagenie.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
.then(function (imageBase64String) {
imagenieLocalForageInstance.setItem(encodeURIComponent(imageSrc), imageBase64String);
ImagenieUtil.setImageToElement(element, imageBase64String);

}, function(error) {
ImagenieUtil.setImageToElement(element, imageSrc);
});
});

Expand All @@ -141,6 +142,8 @@
.then(function (imageBase64String) {
imagenieLocalForageInstance.setItem(encodeURIComponent(imageSrc), imageBase64String);
ImagenieUtil.setImageToElement(element, imageBase64String);
}, function(error) {
ImagenieUtil.setImageToElement(element, imageSrc);
});
});

Expand Down
2 changes: 1 addition & 1 deletion imagenie.min.js

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

5 changes: 4 additions & 1 deletion src/imagenie.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
.then(function (imageBase64String) {
imagenieLocalForageInstance.setItem(encodeURIComponent(imageSrc), imageBase64String);
ImagenieUtil.setImageToElement(element, imageBase64String);

}, function(error) {
ImagenieUtil.setImageToElement(element, imageSrc);
});
});

Expand All @@ -141,6 +142,8 @@
.then(function (imageBase64String) {
imagenieLocalForageInstance.setItem(encodeURIComponent(imageSrc), imageBase64String);
ImagenieUtil.setImageToElement(element, imageBase64String);
}, function(error) {
ImagenieUtil.setImageToElement(element, imageSrc);
});
});

Expand Down

0 comments on commit 5ac8575

Please sign in to comment.