Skip to content

Commit

Permalink
Merge pull request honestbleeps#247 from patricksnape/issue_235
Browse files Browse the repository at this point in the history
Fixes issue honestbleeps#235 by adding an onerror function
  • Loading branch information
honestbleeps committed Feb 13, 2013
2 parents 43858d0 + 831de26 commit 36d3b1d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/reddit_enhancement_suite.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9255,6 +9255,7 @@ modules['showImages'] = {
var thisSrc = (imageLink.type == 'IMAGE_SCRAPE') ? imageLink.getAttribute('scraped_src') : imageLink.src;
$(imageAnchor).html('<img title="drag to resize" class="RESImage" style="max-width:'+this.options.maxWidth.value+'px;max-height:'+this.options.maxHeight.value+'px;" src="' + thisSrc + '" />');
var image = imageAnchor.querySelector('IMG');
image.onerror = imageLink.onerror;

if ('credits' in imageLink) {
var credits = document.createElement('div');
Expand Down Expand Up @@ -9825,6 +9826,13 @@ modules['showImages'] = {
if (RESUtils.pageType() == 'linklist') {
$(elem).closest('.thing').find('.thumbnail').attr('href',elem.href);
}
elem.onerror = function() {
if (this.src.match(/\.jpg/)) {
this.src = this.src.slice(0, elem.src.length - 3) + 'png';
} else if (this.src.match(/\.png/)) {
this.src = this.src.slice(0, elem.src.length - 3) + 'gif';
}
}
modules['showImages'].createImageExpando(elem);
}
},
Expand Down

0 comments on commit 36d3b1d

Please sign in to comment.