diff --git a/apps/web/components/dashboard/bookmarks/AssetCard.tsx b/apps/web/components/dashboard/bookmarks/AssetCard.tsx
index 61b3bc8d..5e6788b5 100644
--- a/apps/web/components/dashboard/bookmarks/AssetCard.tsx
+++ b/apps/web/components/dashboard/bookmarks/AssetCard.tsx
@@ -1,6 +1,5 @@
"use client";
-import Image from "next/image";
import Link from "next/link";
import type { ZBookmarkTypeAsset } from "@hoarder/shared/types/bookmarks";
@@ -8,6 +7,7 @@ import { getAssetUrl } from "@hoarder/shared-react/utils/assetUtils";
import { getSourceUrl } from "@hoarder/shared-react/utils/bookmarkUtils";
import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard";
+import FixedRatioImage from "./FixedRatioImage";
import FooterLinkURL from "./FooterLinkURL";
function AssetImage({
@@ -22,11 +22,11 @@ function AssetImage({
case "image": {
return (
-
);
diff --git a/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx b/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx
index 1df0c197..b701ffd9 100644
--- a/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx
+++ b/apps/web/components/dashboard/bookmarks/BookmarkLayoutAdaptingCard.tsx
@@ -155,18 +155,19 @@ function GridView({
layout,
fitHeight = false,
}: Props & { layout: BookmarksLayoutTypes }) {
- const img = image("grid", "h-56 min-h-56 w-full object-cover rounded-t-lg");
+ const img = image("grid", "w-full object-cover max-h-screen rounded-t-lg");
return (
- {img &&
{img}
}
+ {/* {img &&
{img}
} */}
+ {img &&
{img}
}
{title && (
diff --git a/apps/web/components/dashboard/bookmarks/FixedRatioImage.tsx b/apps/web/components/dashboard/bookmarks/FixedRatioImage.tsx
new file mode 100644
index 00000000..b888f9ac
--- /dev/null
+++ b/apps/web/components/dashboard/bookmarks/FixedRatioImage.tsx
@@ -0,0 +1,40 @@
+"use client";
+
+import { useState } from "react";
+import Image from "next/image";
+
+export default function FixedRatioImage({
+ src,
+ unoptimized,
+ className,
+ alt,
+}: {
+ src: string;
+ unoptimized: boolean;
+ className: string | undefined;
+ alt: string;
+}) {
+ const [height, setHeight] = useState
(0);
+ const [width, setWidth] = useState(0);
+
+ if (height === null) return ;
+
+ const onImgLoad = ({ target }: React.SyntheticEvent) => {
+ const img = target as HTMLImageElement;
+ setHeight(img.offsetHeight);
+ setWidth(img.offsetWidth);
+ };
+
+ return (
+
+ );
+}
diff --git a/apps/web/components/dashboard/bookmarks/LinkCard.tsx b/apps/web/components/dashboard/bookmarks/LinkCard.tsx
index 86eed9e7..5512eae9 100644
--- a/apps/web/components/dashboard/bookmarks/LinkCard.tsx
+++ b/apps/web/components/dashboard/bookmarks/LinkCard.tsx
@@ -11,6 +11,7 @@ import {
} from "@hoarder/shared-react/utils/bookmarkUtils";
import { BookmarkLayoutAdaptingCard } from "./BookmarkLayoutAdaptingCard";
+import FixedRatioImage from "./FixedRatioImage";
import FooterLinkURL from "./FooterLinkURL";
function LinkTitle({ bookmark }: { bookmark: ZBookmarkTypeLink }) {
@@ -48,7 +49,12 @@ function LinkImage({
if (isBookmarkStillCrawling(bookmark)) {
img = imgComponent("/blur.avif", false);
} else if (imageDetails) {
- img = imgComponent(imageDetails.url, !imageDetails.localAsset);
+ img = FixedRatioImage({
+ src: imageDetails.url,
+ unoptimized: !imageDetails.localAsset,
+ className: className,
+ alt: "card banner",
+ });
} else {
// No image found
// A dummy white pixel for when there's no image.