clipper: remove images from clip if images false

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2025-06-11 13:43:53 +05:00
committed by Abdullah Atta
parent 4fbaecc24e
commit faaf1eeadf

View File

@@ -36,7 +36,8 @@ const defaultOptions: Options = {
};
async function getInlinedNode(node: HTMLElement, options: Options) {
const { fonts, stylesheets, inlineImages } = options.inlineOptions || {};
const { fonts, images, stylesheets, inlineImages } =
options.inlineOptions || {};
if (stylesheets) await inlineStylesheets(options.fetchOptions);
@@ -44,6 +45,11 @@ async function getInlinedNode(node: HTMLElement, options: Options) {
if (!clone || clone instanceof Text) return;
if (!images) {
const images = clone.querySelectorAll("img");
images.forEach((image) => image.remove());
}
if (fonts) clone = await embedFonts(clone, options.fetchOptions);
if (inlineImages) await inlineAllImages(clone, options.fetchOptions);