From 0167bcecb714529a0d64ecf86f874004a1ca6f05 Mon Sep 17 00:00:00 2001 From: oneyoung19 <37331643+oneyoung19@users.noreply.github.com> Date: Mon, 23 Sep 2024 21:49:21 +0800 Subject: [PATCH 1/2] Fixed the bug with the '!inline' tags, relates to #15 --- inline-images.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/inline-images.js b/inline-images.js index 5b9185e..3340c81 100644 --- a/inline-images.js +++ b/inline-images.js @@ -47,17 +47,17 @@ function plugin(options = {}){ // Find !inline attribute var not_inline_flag = $img.attr(NOT_INLINE_ATTR); - + if(typeof not_inline_flag !== typeof undefined && not_inline_flag !== false){ // Remove the tag and don't process this file return $img.removeAttr(NOT_INLINE_ATTR); } - + // Count async ops count++; getSrcBase64(options.basedir || file.dirname, getHTTP, src, function(err, result, res_format, skip_formatting){ - if (err) { + if (err) { console.error(err); } else { // Need a format in and a result for this to work @@ -69,7 +69,7 @@ function plugin(options = {}){ } } - if(!--count){ + if(!(count - 1)){ file.contents = Buffer.from($.html()); callback(null, file); } @@ -78,7 +78,8 @@ function plugin(options = {}){ }); // If no files are processing we don't need to wait as none were ever started - if (!img_tags.length){ + // !img_tags.length no matched files, count <= 0 no processed files. + if (!img_tags.length || count <= 0){ file.contents = Buffer.from($.html()); callback(null, file); } @@ -133,7 +134,7 @@ function getSrcBase64(base, getHTTP, src, callback){ } else { callback(null, src, null, true) } - } + } } module.exports.plugin = plugin; From 4db8e6f78f253329cab186c0af92d91c8783834c Mon Sep 17 00:00:00 2001 From: oneyoung19 <37331643+oneyoung19@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:16:09 +0800 Subject: [PATCH 2/2] Fixed the bug with the '!inline' tags, relates to #15 --- inline-images.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inline-images.js b/inline-images.js index 3340c81..b6f729e 100644 --- a/inline-images.js +++ b/inline-images.js @@ -69,7 +69,7 @@ function plugin(options = {}){ } } - if(!(count - 1)){ + if(!--count){ file.contents = Buffer.from($.html()); callback(null, file); }