From 8a9c105810ba6581ade46e3ec869dab34bc57f66 Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Fri, 22 Sep 2023 15:20:42 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20remove=20size=20suffix=20from=20?= =?UTF-8?q?migrated=20WP=20image=20filenames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/model/Gdoc/htmlToEnriched.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db/model/Gdoc/htmlToEnriched.ts b/db/model/Gdoc/htmlToEnriched.ts index 722bdf84990..c22f301c178 100644 --- a/db/model/Gdoc/htmlToEnriched.ts +++ b/db/model/Gdoc/htmlToEnriched.ts @@ -987,9 +987,13 @@ function cheerioToArchieML( { type: "image", // src is the entire path. we only want the filename - filename: path.basename( - image?.attribs["src"] ?? "" - ), + filename: path + .basename(image?.attribs["src"] ?? "") + .replace( + // removing size suffixes e.g. some_file-1280x840.png -> some_file.png + /-\d+x\d+\.(png|jpg|jpeg|gif|svg)$/, + ".$1" + ), alt: image?.attribs["alt"] ?? "", parseErrors: [], originalWidth: undefined,