Skip to content

Commit 86f4d5f

Browse files
thumbnail fix
1 parent 1642471 commit 86f4d5f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/app/api/admin/route.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ export async function POST(req: Request) {
5757
);
5858
} else {
5959
finalUrl = urls[0];
60-
const thumbnailResponse = cloudinary.v2.url(finalUrl!, {
61-
format: "jpg",
62-
page: 1,
63-
transformation: [{ width: 300, height: 400, crop: "fit" }],
64-
});
65-
thumbnailUrl = thumbnailResponse;
60+
const thumbnailResponse = cloudinary.v2.image(finalUrl!, {format: "jpg"});
61+
thumbnailUrl = thumbnailResponse
62+
.replace("pdf", "jpg")
63+
.replace("upload", "upload/w_400,h_400,c_fill")
64+
.replace(/<img src='|'\s*\/>/g, '');
65+
6666
const paper = new Paper({
6767
finalUrl,
6868
thumbnailUrl,
@@ -75,7 +75,7 @@ export async function POST(req: Request) {
7575
}
7676

7777
return NextResponse.json(
78-
{ status: "success", url: finalUrl },
78+
{ status: "success", url: finalUrl, thumbnailUrl: thumbnailUrl },
7979
{ status: 201 },
8080
);
8181
} catch (error) {

0 commit comments

Comments
 (0)