From c1ac4791a70b10e745e7f7c0ee0f57d529fb4dfd Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Thu, 29 Jan 2015 14:24:03 +0800 Subject: [PATCH] Fix: external post preview due to thumbnail extension change Hotfix for post-hover.js external post preview so that it works with the recent change to newly generated thumbnails. --- js/post-hover.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/js/post-hover.js b/js/post-hover.js index fab3a45d..77d17803 100644 --- a/js/post-hover.js +++ b/js/post-hover.js @@ -208,20 +208,32 @@ onready(function(){ $.each(file_array, function () { var thumb_url; - var file_ext = this.ext; + var file_ext = this.ext; if (this.isImage && !this.isSpoiler) { - // video files uses jpg for thumbnail - if (this.ext === '.webm' || this.ext === '.mp4' || this.ext === '.jpeg') this.ext = '.jpg'; + + // at some point around 28/29th of Jan, 2015; all the newly generated thumbnails switched to using jpg + // this is a quick hack to ensure that external preview (mostly) works with old and new posts + + // Note: please update if a more accurate timestamp is known + if (data.last_modified > 1422489600) { + this.ext = '.jpg'; + } else { + if (this.ext === '.webm' || this.ext === '.mp4' || this.ext === '.jpeg') { + this.ext = '.jpg'; + } + } + thumb_url = '/'+ board +'/thumb/' + this.tim + this.ext; + } else { thumb_url = (this.isSpoiler) ? '/static/spoiler.png' : '/static/file.png'; } - // truncate long filenames - if (this.filename.length > 23) { - this.filename = this.filename.substr(0, 22) + '…'; - } + // truncate long filenames + if (this.filename.length > 23) { + this.filename = this.filename.substr(0, 22) + '…'; + } // file infos var $ele = $('
')