diff --git a/js/interface_common.js b/js/interface_common.js index e2ec064..c25f340 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -486,22 +486,10 @@ function postExpandFunction(e, postLi) { var originalLi = $('
  • ', {class: 'module post original'}).appendTo(itemOl) .append(originalPost); + setPostImagePreview(postExpandedContent, originalPost.find('a[rel="nofollow"]')); + postExpandedContent.slideDown('fast'); - if ($.Options.displayPreview.val === 'enable') { - var previewContainer = postExpandedContent.find('.preview-container')[0]; - /* was the preview added before... */ - if ($(previewContainer).children().length === 0) { - var link = originalPost.find('a[rel="nofollow"]'); - /*is there any link in the post?*/ - for (var i = 0; i < link.length; i++) { - if (/^[^?]+\.(?:jpe?g|gif|png)$/i.test(link[i].href)) { - var url = proxyURL(link[i].href); - $(previewContainer).append($('')); - } - } - } - } // insert 'reply_to' before requestRepliedBefore(originalLi); // insert replies to this post after diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 605543c..57dde30 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -695,3 +695,19 @@ function reverseHtmlEntities(str) { .replace(/'/g, "'") .replace(/&/g, '&'); } + +function setPostImagePreview(elem, links) { + if ($.Options.displayPreview.val === 'enable') { + var previewContainer = elem.find('.preview-container'); + // was the preview added before... + if (!previewContainer.children().length) { + // is there any links to images in the post? + for (var i = 0; i < links.length; i++) { + if (/^[^?]+\.(?:jpe?g|gif|png)$/i.test(links[i].href)) { + var url = proxyURL(links[i].href); + previewContainer.append($('')); + } + } + } + } +}