fix image 404 redirect
This commit is contained in:
parent
758a36d2f6
commit
f80fe44aea
@ -183,7 +183,7 @@ Gallery =
|
|||||||
error: (file, thumb) ->
|
error: (file, thumb) ->
|
||||||
if file.error?.code is MediaError.MEDIA_ERR_DECODE
|
if file.error?.code is MediaError.MEDIA_ERR_DECODE
|
||||||
return new Notice 'error', 'Corrupt or unplayable video', 30
|
return new Notice 'error', 'Corrupt or unplayable video', 30
|
||||||
ImageCommon.error g.posts[file.dataset.post], null, ->
|
ImageCommon.error file, g.posts[file.dataset.post], null, (URL) ->
|
||||||
return unless URL
|
return unless URL
|
||||||
thumb.href = URL
|
thumb.href = URL
|
||||||
file.src = URL if Gallery.nodes.current is file
|
file.src = URL if Gallery.nodes.current is file
|
||||||
|
|||||||
@ -7,7 +7,10 @@ ImageCommon =
|
|||||||
message.textContent = 'Error: Corrupt or unplayable video'
|
message.textContent = 'Error: Corrupt or unplayable video'
|
||||||
return true
|
return true
|
||||||
|
|
||||||
error: (post, delay, cb) ->
|
error: (file, post, delay, cb) ->
|
||||||
|
if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org'
|
||||||
|
ImageCommon.retry post, cb
|
||||||
|
|
||||||
timeoutID = setTimeout ImageCommon.retry, delay, post, cb if delay?
|
timeoutID = setTimeout ImageCommon.retry, delay, post, cb if delay?
|
||||||
return if post.isDead or post.file.isDead
|
return if post.isDead or post.file.isDead
|
||||||
kill = (fileOnly) ->
|
kill = (fileOnly) ->
|
||||||
@ -25,6 +28,7 @@ ImageCommon =
|
|||||||
<% } else { %>
|
<% } else { %>
|
||||||
# XXX CORS for i.4cdn.org WHEN?
|
# XXX CORS for i.4cdn.org WHEN?
|
||||||
$.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: ->
|
$.ajax "//a.4cdn.org/#{post.board}/thread/#{post.thread}.json", onload: ->
|
||||||
|
return kill() if @status is 404
|
||||||
return if @status isnt 200
|
return if @status isnt 200
|
||||||
for postObj in @response.posts
|
for postObj in @response.posts
|
||||||
break if postObj.no is post.ID
|
break if postObj.no is post.ID
|
||||||
@ -37,9 +41,10 @@ ImageCommon =
|
|||||||
retry: (post, cb) ->
|
retry: (post, cb) ->
|
||||||
unless post.isDead or post.file.isDead
|
unless post.isDead or post.file.isDead
|
||||||
return cb post.file.URL + '?' + Date.now()
|
return cb post.file.URL + '?' + Date.now()
|
||||||
|
src = post.file.URL.split '/'
|
||||||
URL = Redirect.to 'file',
|
URL = Redirect.to 'file',
|
||||||
boardID: post.board.ID
|
boardID: post.board.ID
|
||||||
filename: post.file.URL
|
filename: src[src.length - 1]
|
||||||
if URL and (/^https:\/\//.test(URL) or location.protocol is 'http:')
|
if URL and (/^https:\/\//.test(URL) or location.protocol is 'http:')
|
||||||
return cb URL
|
return cb URL
|
||||||
cb null # report nothing to retry
|
cb null # report nothing to retry
|
||||||
|
|||||||
@ -253,7 +253,7 @@ ImageExpand =
|
|||||||
# - after the image started loading.
|
# - after the image started loading.
|
||||||
# Don't try to re-expand if it was already contracted.
|
# Don't try to re-expand if it was already contracted.
|
||||||
if post.file.isExpanding or post.file.isExpanded
|
if post.file.isExpanding or post.file.isExpanded
|
||||||
ImageCommon.error post, 10 * $.SECOND, (URL) ->
|
ImageCommon.error @, post, 10 * $.SECOND, (URL) ->
|
||||||
if post.file.isExpanding or post.file.isExpanded
|
if post.file.isExpanding or post.file.isExpanded
|
||||||
ImageExpand.contract post
|
ImageExpand.contract post
|
||||||
ImageExpand.expand post, URL if URL
|
ImageExpand.expand post, URL if URL
|
||||||
|
|||||||
@ -44,5 +44,4 @@ ImageHover =
|
|||||||
return unless doc.contains @
|
return unless doc.contains @
|
||||||
post = g.posts[@dataset.fullID]
|
post = g.posts[@dataset.fullID]
|
||||||
return if ImageCommon.decodeError @, post
|
return if ImageCommon.decodeError @, post
|
||||||
ImageCommon.error post, 3 * $.SECOND, ->
|
ImageCommon.error @, post, 3 * $.SECOND, (URL) => @src = URL if URL
|
||||||
@src = URL if URL
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user