diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index c9af0a390..5d3de63ff 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -194,7 +194,7 @@ Gallery = error: -> if @error?.code is MediaError.MEDIA_ERR_DECODE return new Notice 'error', 'Corrupt or unplayable video', 30 - return unless @src.split('/')[2] is 'i.4cdn.org' + return if ImageCommon.isFromArchive @ ImageCommon.error @, g.posts[@dataset.post], null, (url) => return unless url Gallery.images[@dataset.id].href = url diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index 4b8b7396f..9e2f1ece8 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -33,6 +33,9 @@ ImageCommon = message.textContent = 'Error: Corrupt or unplayable video' return true + isFromArchive: (file) -> + file.src.split('/')[2] isnt 'i.4cdn.org' + error: (file, post, delay, cb) -> src = post.file.url.split '/' URL = Redirect.to 'file', { @@ -42,12 +45,12 @@ ImageCommon = unless Conf['404 Redirect'] and URL and Redirect.securityCheck URL URL = null - return cb URL if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org' + return cb URL if (post.isDead or post.file.isDead) and not ImageCommon.isFromArchive file timeoutID = setTimeout (-> cb URL), delay if delay? return if post.isDead or post.file.isDead redirect = -> - if file.src.split('/')[2] is 'i.4cdn.org' + unless ImageCommon.isFromArchive file clearTimeout timeoutID if delay? cb URL diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index d44fc01e8..3ad07a30a 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -268,7 +268,7 @@ ImageExpand = if ImageCommon.decodeError @, post return ImageExpand.contract post # Don't autoretry images from the archive. - unless @src.split('/')[2] is 'i.4cdn.org' + if ImageCommon.isFromArchive @ return ImageExpand.contract post ImageCommon.error @, post, 10 * $.SECOND, (URL) -> if post.file.isExpanding or post.file.isExpanded