feat: add fit in ImgThumb

This commit is contained in:
rizky 2024-08-14 01:26:46 -07:00
parent d733a1c52b
commit d611e4f4a4
2 changed files with 5 additions and 2 deletions

View File

@ -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'}`
)}
/>
)}

View File

@ -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;
};