Skip to content

Commit 1c85924

Browse files
committed
Updated to ignore process image which already wrapped by link node
1 parent 8b16e07 commit 1c85924

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

public/js/extra.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,22 @@ function finishView(view) {
260260
//image href new window(emoji not included)
261261
var images = view.find("img.raw[src]").removeClass("raw");
262262
images.each(function (key, value) {
263+
// if it's already wrapped by link, then ignore
264+
var $value = $(value);
265+
if ($value.parent()[0].nodeName === 'A') return;
263266
var src = $(value).attr('src');
264267
var a = $('<a>');
265268
if (src) {
266269
a.attr('href', src);
267270
a.attr('target', "_blank");
268271
}
269-
var clone = $(value).clone();
272+
var clone = $value.clone();
270273
clone[0].onload = function (e) {
271274
if(viewAjaxCallback)
272275
viewAjaxCallback();
273276
};
274277
a.html(clone);
275-
$(value).replaceWith(a);
278+
$value.replaceWith(a);
276279
});
277280
//blockquote
278281
var blockquote = view.find("blockquote.raw").removeClass("raw");

0 commit comments

Comments
 (0)