From d611e4f4a4106ec92e2fd3912969423c6bb02889 Mon Sep 17 00:00:00 2001 From: rizky Date: Wed, 14 Aug 2024 01:26:46 -0700 Subject: [PATCH] feat: add fit in ImgThumb --- comps/form/field/type/FilePreview.tsx | 4 +++- utils/baseurl.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/comps/form/field/type/FilePreview.tsx b/comps/form/field/type/FilePreview.tsx index 60d1085..8bab47a 100755 --- a/comps/form/field/type/FilePreview.tsx +++ b/comps/form/field/type/FilePreview.tsx @@ -296,11 +296,13 @@ export const ImgThumb = ({ url, w, h, + fit }: { className?: string; url: string; w: number; h: number; + fit?: 'cover' | 'contain', }) => { const local = useLocal({ error: false }); return ( @@ -327,7 +329,7 @@ export const ImgThumb = ({ local.render(); }} src={siteurl( - `/_img/${url.substring("_file/".length)}?w=${w}&h=${h}&fit=cover` + `/_img/${url.substring("_file/".length)}?w=${w}&h=${h}&fit=${fit || 'cover'}` )} /> )} diff --git a/utils/baseurl.ts b/utils/baseurl.ts index 0a061f3..039133c 100755 --- a/utils/baseurl.ts +++ b/utils/baseurl.ts @@ -1,7 +1,8 @@ export const baseurl = (url: string) => { if (location.hostname === "prasi.avolut.com") { const id_site = location.pathname.split("/")[2]; - return `/prod/${id_site}${url}` + if (url.startsWith("/")) return `/prod/${id_site}${url}`; + else return `/prod/${id_site}/${url}`; } return url; };