diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index 014a17923..1810fa3e7 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -183,6 +183,7 @@ Gallery = error: (file, thumb) -> if file.error?.code is MediaError.MEDIA_ERR_DECODE return new Notice 'error', 'Corrupt or unplayable video', 30 + return unless file.src.split('/')[2] is 'i.4cdn.org' ImageCommon.error file, g.posts[file.dataset.post], null, (URL) -> return unless URL thumb.href = URL diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index 2310483f0..e5bec60b4 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -17,31 +17,38 @@ ImageCommon = return cb URL if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org' - timeoutID = setTimeout cb, delay, post.file.URL if delay? + timeoutID = setTimeout (-> cb URL), delay if delay? return if post.isDead or post.file.isDead - kill = (fileOnly) -> - clearTimeout timeoutID if delay? - post.kill fileOnly - cb URL + redirect = -> + if file.src.split('/')[2] is 'i.4cdn.org' + clearTimeout timeoutID if delay? + cb URL <% if (type === 'crx') { %> $.ajax post.file.URL, onloadend: -> - return if @status isnt 404 - kill true + if @status is 200 + URL = post.file.URL + else + post.kill true if @status is 404 + redirect() , type: 'head' <% } else { %> # XXX CORS for i.4cdn.org WHEN? $.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: -> - return kill() if @status is 404 - return if @status isnt 200 + post.kill() if @status is 404 + return redirect() if @status isnt 200 for postObj in @response.posts break if postObj.no is post.ID if postObj.no isnt post.ID - kill() + post.kill() + redirect() else if postObj.filedeleted - kill true + post.kill true + redirect() + else + URL = post.file.URL <% } %> # Add controls, but not until the mouse is moved over the video.