Deal with unavailable images.

This commit is contained in:
Nicolas Stepien 2012-06-17 21:40:39 +02:00
parent 72c219cc6f
commit eefcf6b096
2 changed files with 5 additions and 3 deletions

View File

@ -3141,7 +3141,7 @@
}
},
parseArchivedPost: function(req, board, postID, root, cb) {
var bq, br, capcode, data, email, file, filename, filesize, isOP, max, name, nameBlock, pc, pi, piM, span, subject, threadID, timestamp, trip;
var bq, br, capcode, data, email, file, filename, filesize, isOP, max, name, nameBlock, pc, pi, piM, span, subject, threadID, thumb_src, timestamp, trip;
data = JSON.parse(req.response);
$.addClass(root, 'archivedPost');
if (data.error) {
@ -3280,11 +3280,12 @@
span.title = filename;
max = isOP ? 40 : 30;
span.textContent = filename.replace(/\.\w+$/, '').length > max ? "" + filename.slice(0, max) + "(...)" + (filename.match(/\.\w+$/)) : filename;
thumb_src = data.media_status === 'available' ? "src=" + data.thumb_link : '';
$.add(file, $.el('a', {
className: 'fileThumb',
href: data.media_link || data.remote_media_link,
target: '_blank',
innerHTML: "<img src=" + data.thumb_link + " alt='" + (data.spoiler === '1' ? 'Spoiler Image, ' : '') + filesize + "' data-md5=" + data.media_hash + " style='height: " + data.preview_h + "px; width: " + data.preview_w + "px;'>"
innerHTML: "<img " + thumb_src + " alt='" + (data.media_status !== 'available' ? "Error: " + data.media_status + ", " : '') + (data.spoiler === '1' ? 'Spoiler Image, ' : '') + filesize + "' data-md5=" + data.media_hash + " style='height: " + data.preview_h + "px; width: " + data.preview_w + "px;'>"
}));
$.after((isOP ? piM : pi), file);
}

View File

@ -2568,11 +2568,12 @@ Get =
"#{filename[...max]}(...)#{filename.match(/\.\w+$/)}"
else
filename
thumb_src = if data.media_status is 'available' then "src=#{data.thumb_link}" else ''
$.add file, $.el 'a',
className: 'fileThumb'
href: data.media_link or data.remote_media_link
target: '_blank'
innerHTML: "<img src=#{data.thumb_link} alt='#{if data.spoiler is '1' then 'Spoiler Image, ' else ''}#{filesize}' data-md5=#{data.media_hash} style='height: #{data.preview_h}px; width: #{data.preview_w}px;'>"
innerHTML: "<img #{thumb_src} alt='#{if data.media_status isnt 'available' then "Error: #{data.media_status}, " else ''}#{if data.spoiler is '1' then 'Spoiler Image, ' else ''}#{filesize}' data-md5=#{data.media_hash} style='height: #{data.preview_h}px; width: #{data.preview_w}px;'>"
$.after (if isOP then piM else pi), file
$.replace root.firstChild, pc