diff --git a/server/core/fb2/Fb2Helper.js b/server/core/fb2/Fb2Helper.js index 5a3383b..e2b1de3 100644 --- a/server/core/fb2/Fb2Helper.js +++ b/server/core/fb2/Fb2Helper.js @@ -70,9 +70,6 @@ class Fb2Helper { if (coverImage.count) { const coverAttrs = coverImage.attrs(); const href = coverAttrs[`${parser.xlinkNS}:href`]; - let coverType = coverAttrs['content-type']; - coverType = (coverType == 'image/jpg' || coverType == 'application/octet-stream' ? 'image/jpeg' : coverType); - coverExt = (coverType == 'image/png' ? '.png' : '.jpg'); if (href) { const binaryId = (href[0] == '#' ? href.substring(1) : href); @@ -84,6 +81,10 @@ class Fb2Helper { return; if (attrs.id === binaryId) { + let coverType = attrs['content-type']; + coverType = (coverType == 'image/jpg' || coverType == 'application/octet-stream' ? 'image/jpeg' : coverType); + coverExt = (coverType == 'image/png' ? '.png' : '.jpg'); + const base64 = node.text(); cover = (base64 ? Buffer.from(base64, 'base64') : null); }