From f8ef5341c70a2aee6b22751eebc500ed24c7825f Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Thu, 2 Jul 2015 20:29:31 +0800 Subject: Optimized image rendering, avoid duplicated image load when content changed --- public/js/extra.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'public/js/extra.js') diff --git a/public/js/extra.js b/public/js/extra.js index f6d47647..084ebe8a 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -128,7 +128,7 @@ function finishView(view) { } }); //image href new window(emoji not included) - var images = view.find("p > img[src]:not([class])"); + var images = view.find("img.raw[src]").removeClass("raw"); images.each(function (key, value) { var src = $(value).attr('src'); var a = $(''); @@ -136,7 +136,12 @@ function finishView(view) { a.attr('href', src); a.attr('target', "_blank"); } - a.html($(value).clone()); + var clone = $(value).clone(); + clone[0].onload = function (e) { + if(viewAjaxCallback) + viewAjaxCallback(); + }; + a.html(clone); $(value).replaceWith(a); }); //blockquote -- cgit v1.2.3