mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-01-12 16:07:59 +00:00
move image preview setup to ~setPostImagePreview()~ in twister_formatpost.js and fix it slightly
This commit is contained in:
parent
3f20e20945
commit
ea144e63f9
@ -486,22 +486,10 @@ function postExpandFunction(e, postLi) {
|
||||
var originalLi = $('<li/>', {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($('<img src="' + url + '" class="image-preview" />'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// insert 'reply_to' before
|
||||
requestRepliedBefore(originalLi);
|
||||
// insert replies to this post after
|
||||
|
@ -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($('<img src="' + url + '" class="image-preview" />'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user