Skip to content

Commit

Permalink
🐛 remove size suffix from migrated WP image filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Oct 13, 2023
1 parent 552f837 commit 8a9c105
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions db/model/Gdoc/htmlToEnriched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8a9c105

Please sign in to comment.