diff --git a/package-lock.json b/package-lock.json
index c5d749a..b398c93 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21,6 +21,7 @@
"@trpc/client": "^11.17.0",
"@trpc/server": "^11.17.0",
"@trpc/tanstack-react-query": "^11.17.0",
+ "blurhash": "^2.0.5",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"embla-carousel-react": "^8.6.0",
@@ -7377,6 +7378,12 @@
"require-from-string": "^2.0.2"
}
},
+ "node_modules/blurhash": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.5.tgz",
+ "integrity": "sha512-cRygWd7kGBQO3VEhPiTgq4Wc43ctsM+o46urrmPOiuAe+07fzlSB9OJVdpgDL0jPqXUVQ9ht7aq7kxOeJHRK+w==",
+ "license": "MIT"
+ },
"node_modules/body-parser": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",
diff --git a/package.json b/package.json
index 093bd0d..148d667 100644
--- a/package.json
+++ b/package.json
@@ -25,6 +25,7 @@
"@trpc/client": "^11.17.0",
"@trpc/server": "^11.17.0",
"@trpc/tanstack-react-query": "^11.17.0",
+ "blurhash": "^2.0.5",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"embla-carousel-react": "^8.6.0",
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index c4f4fc4..6974e46 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -221,13 +221,14 @@ model Post {
}
model PostImage {
- id String @id @default(cuid())
- post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
+ id String @id @default(cuid())
+ post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
postId String
storageKey String // Supabase Storage object key
position Int // 0-based order in carousel
width Int?
height Int?
+ blurhash String? // computed client-side at upload (src/lib/blurhash.ts), decoded as a loading placeholder
@@unique([postId, position])
@@index([postId])
@@ -246,6 +247,7 @@ model Story {
pet Pet @relation(fields: [petId], references: [id], onDelete: Cascade)
petId String
storageKey String // Supabase Storage object key
+ blurhash String? // computed client-side at upload (src/lib/blurhash.ts), decoded as a loading placeholder
expiresAt DateTime // set to NOW() + 24 hours on create (D-07)
views StoryView[]
createdAt DateTime @default(now())
diff --git a/src/__tests__/posts.test.ts b/src/__tests__/posts.test.ts
index 773eb0d..0fa8ab4 100644
--- a/src/__tests__/posts.test.ts
+++ b/src/__tests__/posts.test.ts
@@ -121,7 +121,7 @@ describe("posts.create", () => {
const result = await caller.create({
petId: "pet-1",
caption: "Hello world",
- imageKeys: ["posts/owner-1/pet-1/uuid.jpg"],
+ images: [{ key: "posts/owner-1/pet-1/uuid.jpg", blurhash: "L6PZfSi_.AyE_3t7t7R**0o#DgR4" }],
});
// Post was created
@@ -157,10 +157,10 @@ describe("posts.create", () => {
caller.create({
petId: "pet-1",
caption: null,
- imageKeys: Array.from(
- { length: 11 },
- (_, i) => `posts/owner-1/pet-1/img-${i}.jpg`
- ),
+ images: Array.from({ length: 11 }, (_, i) => ({
+ key: `posts/owner-1/pet-1/img-${i}.jpg`,
+ blurhash: null,
+ })),
})
).rejects.toThrow(TRPCError);
});
diff --git a/src/app/(app)/explore/page.tsx b/src/app/(app)/explore/page.tsx
index 75300ef..6df636a 100644
--- a/src/app/(app)/explore/page.tsx
+++ b/src/app/(app)/explore/page.tsx
@@ -12,6 +12,7 @@ import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Badge } from "@/components/ui/badge";
import { PostDetailDialog } from "@/components/feed/PostDetailDialog";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
import type { PostCardPost } from "@/components/feed/PostCard";
import {
Select,
@@ -202,7 +203,7 @@ type TrendingPost = {
caption: string | null;
createdAt: Date | string;
pet: { id: string; name: string; avatarKey: string | null };
- images: { storageKey: string; position: number }[];
+ images: { storageKey: string; position: number; blurhash?: string | null }[];
milestone: { milestoneType: string; notes: string | null } | null;
reactionCount: number;
commentCount: number;
@@ -299,9 +300,9 @@ function TrendingContent({
aria-label={post.caption ?? "View trending post"}
>
{mediaUrl ? (
- // eslint-disable-next-line @next/next/no-img-element
-
diff --git a/src/app/(app)/hashtag/[tag]/page.tsx b/src/app/(app)/hashtag/[tag]/page.tsx
index 9a324ba..2c7cd0b 100644
--- a/src/app/(app)/hashtag/[tag]/page.tsx
+++ b/src/app/(app)/hashtag/[tag]/page.tsx
@@ -7,6 +7,7 @@ import { useEffect } from "react";
import { Layers2, Loader2 } from "lucide-react";
import { useTRPC } from "@/trpc/client";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
interface PageProps {
params: Promise<{ tag: string }>;
@@ -62,7 +63,7 @@ export default function HashtagPage({ params }: PageProps) {
const p = post as {
id: string;
caption: string | null;
- images: Array<{ storageKey: string; position?: number }>;
+ images: Array<{ storageKey: string; position?: number; blurhash?: string | null }>;
};
const firstImage = p.images?.[0];
const isCarousel = (p.images?.length ?? 0) > 1;
@@ -74,9 +75,9 @@ export default function HashtagPage({ params }: PageProps) {
className="relative aspect-square overflow-hidden bg-muted"
>
{mediaUrl ? (
- // eslint-disable-next-line @next/next/no-img-element
-
diff --git a/src/app/(app)/notifications/page.tsx b/src/app/(app)/notifications/page.tsx
index 2b97f44..5a8e5d3 100644
--- a/src/app/(app)/notifications/page.tsx
+++ b/src/app/(app)/notifications/page.tsx
@@ -10,6 +10,7 @@ import { useActivePet } from "@/context/ActivePetContext";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { getAvatarUrl } from "@/lib/avatar-url";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
import { useTranslations } from "next-intl";
import { formatRelativeCompact } from "@/lib/format-relative-time";
@@ -191,9 +192,9 @@ export default function NotificationsPage() {
{/* Post thumbnail (for REACTION / COMMENT) */}
{postThumbUrl && (
- {/* eslint-disable-next-line @next/next/no-img-element */}
-

diff --git a/src/app/(app)/search/page.tsx b/src/app/(app)/search/page.tsx
index c47018c..6dbc321 100644
--- a/src/app/(app)/search/page.tsx
+++ b/src/app/(app)/search/page.tsx
@@ -15,6 +15,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { FollowButton } from "@/components/social/FollowButton";
import { getAvatarUrl } from "@/lib/avatar-url";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
export default function SearchPage() {
const t = useTranslations("Search");
@@ -250,7 +251,7 @@ export default function SearchPage() {
const p = post as {
id: string;
caption: string | null;
- images: Array<{ storageKey: string }>;
+ images: Array<{ storageKey: string; blurhash?: string | null }>;
};
const firstImage = p.images?.[0];
const isCarousel = (p.images?.length ?? 0) > 1;
@@ -258,9 +259,9 @@ export default function SearchPage() {
return (
{mediaUrl ? (
- // eslint-disable-next-line @next/next/no-img-element
-

diff --git a/src/app/p/[secret]/posts/page.tsx b/src/app/p/[secret]/posts/page.tsx
index 58b8dd9..e6ad5ca 100644
--- a/src/app/p/[secret]/posts/page.tsx
+++ b/src/app/p/[secret]/posts/page.tsx
@@ -8,6 +8,7 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
export default function AdminPostsPage() {
const trpc = useTRPC();
@@ -90,9 +91,9 @@ export default function AdminPostsPage() {
className="flex items-center gap-4 rounded-xl border border-zinc-800 bg-zinc-900 px-4 py-3"
>
{thumb ? (
- // eslint-disable-next-line @next/next/no-img-element
-
)
diff --git a/src/app/p/[secret]/reports/page.tsx b/src/app/p/[secret]/reports/page.tsx
index 6984c8d..3be3a18 100644
--- a/src/app/p/[secret]/reports/page.tsx
+++ b/src/app/p/[secret]/reports/page.tsx
@@ -4,6 +4,7 @@ import { useState } from "react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
import { Flag, Trash2, X, Loader2, CheckCheck, MessageCircle, Heart, ImageOff } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -150,10 +151,10 @@ export default function AdminReportsPage() {
{report.post.images.length > 0 ? (
report.post.images.map((img, i) => (
- // eslint-disable-next-line @next/next/no-img-element
-
)
diff --git a/src/components/feed/MilestoneCard.tsx b/src/components/feed/MilestoneCard.tsx
index 4674f82..5f8181b 100644
--- a/src/components/feed/MilestoneCard.tsx
+++ b/src/components/feed/MilestoneCard.tsx
@@ -4,6 +4,7 @@ import type { MilestoneType } from "@prisma/client";
import { MILESTONE_META } from "@/lib/milestone-meta";
import { getAvatarUrl } from "@/lib/avatar-url";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
type MilestoneCardPost = {
@@ -11,7 +12,7 @@ type MilestoneCardPost = {
caption: string | null;
createdAt: Date | string;
pet: { id: string; name: string; avatarKey: string | null };
- images: { id: string; storageKey: string; position: number }[];
+ images: { id: string; storageKey: string; position: number; blurhash?: string | null }[];
milestone: { milestoneType: MilestoneType; notes: string | null } | null;
};
@@ -71,9 +72,9 @@ export function MilestoneCard({ post }: MilestoneCardProps) {
{/* Optional photo */}
{photo && (
- {/* eslint-disable-next-line @next/next/no-img-element */}
-
)
diff --git a/src/components/feed/PostCard.tsx b/src/components/feed/PostCard.tsx
index e2566f7..1c4b259 100644
--- a/src/components/feed/PostCard.tsx
+++ b/src/components/feed/PostCard.tsx
@@ -7,6 +7,7 @@ import { useMutation } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";
import { useActivePet } from "@/context/ActivePetContext";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
+import { BlurImage } from "@/components/ui/blur-image";
import {
Carousel,
CarouselContent,
@@ -69,6 +70,7 @@ type PostImage = {
id: string;
storageKey: string;
position: number;
+ blurhash?: string | null;
};
type PostPet = {
@@ -324,9 +326,9 @@ function PostCardImpl({ post, onDeleted, variant = "feed" }: PostCardProps) {
{images.map((img) => (
- {/* eslint-disable-next-line @next/next/no-img-element */}
-
setShowDetailDialog(true)}
@@ -361,9 +363,9 @@ function PostCardImpl({ post, onDeleted, variant = "feed" }: PostCardProps) {
) : (
/* Single image */
- // eslint-disable-next-line @next/next/no-img-element
-
)
setShowDetailDialog(true)}
diff --git a/src/components/feed/PostDetailDialog.tsx b/src/components/feed/PostDetailDialog.tsx
index df7a957..38d73bc 100644
--- a/src/components/feed/PostDetailDialog.tsx
+++ b/src/components/feed/PostDetailDialog.tsx
@@ -38,6 +38,7 @@ import {
import Link from "next/link";
import { getAvatarUrl } from "@/lib/avatar-url";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
import { parseCaption } from "@/lib/parse-caption";
import { formatRelativeCompact } from "@/lib/format-relative-time";
import { PawButton } from "@/components/feed/PawButton";
@@ -260,9 +261,9 @@ export function PostDetailDialog({ post, open, onClose, onDeleted }: PostDetailD
{images.map((img) => (
- {/* eslint-disable-next-line @next/next/no-img-element */}
-
@@ -287,9 +288,9 @@ export function PostDetailDialog({ post, open, onClose, onDeleted }: PostDetailD
) : (
- // eslint-disable-next-line @next/next/no-img-element
-
)
diff --git a/src/components/feed/RepostCard.tsx b/src/components/feed/RepostCard.tsx
index 5da4491..d1ece77 100644
--- a/src/components/feed/RepostCard.tsx
+++ b/src/components/feed/RepostCard.tsx
@@ -16,6 +16,7 @@ import {
} from "@/components/ui/carousel";
import { getAvatarUrl } from "@/lib/avatar-url";
import { getMediaUrl } from "@/lib/media-url";
+import { BlurImage } from "@/components/ui/blur-image";
import { MilestoneCard } from "@/components/feed/MilestoneCard";
import type { PostCardPost } from "@/components/feed/PostCard";
@@ -119,9 +120,9 @@ function RepostCardInner({
{origImages.map((img) => (
- {/* eslint-disable-next-line @next/next/no-img-element */}
-
@@ -137,9 +138,9 @@ function RepostCardInner({
) : (
- {/* eslint-disable-next-line @next/next/no-img-element */}
-
)
diff --git a/src/components/post-creation/MilestoneForm.tsx b/src/components/post-creation/MilestoneForm.tsx
index a45dd67..7403b3c 100644
--- a/src/components/post-creation/MilestoneForm.tsx
+++ b/src/components/post-creation/MilestoneForm.tsx
@@ -17,6 +17,7 @@ import {
PopoverTrigger,
} from "@/components/ui/popover";
import { MILESTONE_META, USER_INITIATED_MILESTONE_TYPES } from "@/lib/milestone-meta";
+import { computeBlurhash } from "@/lib/blurhash";
const ALLOWED_TYPES = ["image/jpeg", "image/png", "image/webp"] as const;
type AllowedContentType = (typeof ALLOWED_TYPES)[number];
@@ -55,6 +56,7 @@ export function MilestoneForm({ onClose }: MilestoneFormProps) {
const [uploadProgress, setUploadProgress] = useState(0);
const [previewUrl, setPreviewUrl] = useState
(null);
const [uploadedKey, setUploadedKey] = useState(null);
+ const [uploadedBlurhash, setUploadedBlurhash] = useState(null);
const [uploadError, setUploadError] = useState(null);
const getPresignedUrlMutation = useMutation(
@@ -95,11 +97,14 @@ export function MilestoneForm({ onClose }: MilestoneFormProps) {
setUploadProgress(0);
try {
- const { presignedUrl, key } = await getPresignedUrlMutation.mutateAsync({
- petId: activePetId,
- contentType: file.type as AllowedContentType,
- fileSize: file.size,
- });
+ const [{ presignedUrl, key }, blurhash] = await Promise.all([
+ getPresignedUrlMutation.mutateAsync({
+ petId: activePetId,
+ contentType: file.type as AllowedContentType,
+ fileSize: file.size,
+ }),
+ computeBlurhash(file),
+ ]);
await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
@@ -114,6 +119,7 @@ export function MilestoneForm({ onClose }: MilestoneFormProps) {
});
setUploadedKey(key);
+ setUploadedBlurhash(blurhash);
setUploadState("ready");
} catch {
setUploadError(t("uploadFailed"));
@@ -142,8 +148,9 @@ export function MilestoneForm({ onClose }: MilestoneFormProps) {
notes: selectedType === MilestoneType.LITTER ? notes.trim() || undefined : undefined,
caption: caption.trim() || undefined,
imageKey: uploadedKey ?? undefined,
+ imageBlurhash: uploadedBlurhash,
});
- }, [activePetId, selectedType, notes, caption, uploadedKey, createMutation]);
+ }, [activePetId, selectedType, notes, caption, uploadedKey, uploadedBlurhash, createMutation]);
const selectedMeta = selectedType ? MILESTONE_META[selectedType] : null;
diff --git a/src/components/post-creation/MultiImageUpload.tsx b/src/components/post-creation/MultiImageUpload.tsx
index 9400b18..a71a1ab 100644
--- a/src/components/post-creation/MultiImageUpload.tsx
+++ b/src/components/post-creation/MultiImageUpload.tsx
@@ -6,6 +6,7 @@ import { toast } from "sonner";
import { useTRPC } from "@/trpc/client";
import { useMutation } from "@tanstack/react-query";
import { uploadFileWithProgress } from "@/lib/upload-xhr";
+import { computeBlurhash } from "@/lib/blurhash";
/**
* MultiImageUpload — multi-file upload zone for post images (up to 10).
@@ -36,6 +37,8 @@ interface UploadedImage {
previewUrl: string;
/** Supabase storage key — only set after successful upload */
storageKey: string | null;
+ /** Blurhash placeholder computed client-side from the selected file (Gitea #1) */
+ blurhash: string | null;
/** File size for display */
fileName: string;
/** Upload state */
@@ -45,15 +48,15 @@ interface UploadedImage {
interface MultiImageUploadProps {
petId: string;
- /** Called with all successfully uploaded storage keys */
- onKeysChange: (keys: string[]) => void;
+ /** Called with all successfully uploaded storage keys + their blurhash placeholders */
+ onImagesChange: (images: { key: string; blurhash: string | null }[]) => void;
/** Max number of images (default 10) */
maxImages?: number;
}
export function MultiImageUpload({
petId,
- onKeysChange,
+ onImagesChange,
maxImages = MAX_IMAGES,
}: MultiImageUploadProps) {
const trpc = useTRPC();
@@ -61,14 +64,14 @@ export function MultiImageUpload({
const [images, setImages] = useState([]);
const [isDragging, setIsDragging] = useState(false);
- // Notify parent of done keys whenever images change — must be outside setImages updater
+ // Notify parent of done images whenever they change — must be outside setImages updater
// to avoid "Cannot update a component while rendering a different component" warning.
useEffect(() => {
- const keys = images
+ const done = images
.filter((img) => img.status === "done" && img.storageKey)
- .map((img) => img.storageKey as string);
- onKeysChange(keys);
- }, [images, onKeysChange]);
+ .map((img) => ({ key: img.storageKey as string, blurhash: img.blurhash }));
+ onImagesChange(done);
+ }, [images, onImagesChange]);
const getPresignedUrlMutation = useMutation(
trpc.posts.getPresignedUrl.mutationOptions()
@@ -106,12 +109,16 @@ export function MultiImageUpload({
});
try {
- // Step 1: Get presigned URL
- const { presignedUrl, key } = await getPresignedUrlMutation.mutateAsync({
- petId,
- contentType: file.type as AllowedContentType,
- fileSize: file.size,
- });
+ // Step 1: Get presigned URL, and in parallel compute the blurhash placeholder
+ // client-side (Gitea #1) — both run concurrently since neither depends on the other.
+ const [{ presignedUrl, key }, blurhash] = await Promise.all([
+ getPresignedUrlMutation.mutateAsync({
+ petId,
+ contentType: file.type as AllowedContentType,
+ fileSize: file.size,
+ }),
+ computeBlurhash(file),
+ ]);
// Step 2: PUT file directly to Supabase Storage, tracking progress
await uploadFileWithProgress(presignedUrl, file, {
@@ -125,13 +132,14 @@ export function MultiImageUpload({
},
});
- // Step 3: Mark as done with storage key
+ // Step 3: Mark as done with storage key + blurhash
setImages((prev) => {
const updated = [...prev];
updated[index] = {
...updated[index],
status: "done",
storageKey: key,
+ blurhash,
uploadProgress: 100,
};
return updated;
@@ -171,6 +179,7 @@ export function MultiImageUpload({
const newImages: UploadedImage[] = toUpload.map((file) => ({
previewUrl: URL.createObjectURL(file),
storageKey: null,
+ blurhash: null,
fileName: file.name,
status: "pending",
uploadProgress: 0,
diff --git a/src/components/post-creation/PhotoPostForm.tsx b/src/components/post-creation/PhotoPostForm.tsx
index e5c072a..6e42f10 100644
--- a/src/components/post-creation/PhotoPostForm.tsx
+++ b/src/components/post-creation/PhotoPostForm.tsx
@@ -44,7 +44,7 @@ export function PhotoPostForm({ onClose }: PhotoPostFormProps) {
const queryClient = useQueryClient();
const { activePetId } = useActivePet();
- const [imageKeys, setImageKeys] = useState([]);
+ const [images, setImages] = useState<{ key: string; blurhash: string | null }[]>([]);
const [caption, setCaption] = useState("");
const [captionError, setCaptionError] = useState(null);
@@ -70,7 +70,7 @@ export function PhotoPostForm({ onClose }: PhotoPostFormProps) {
return;
}
- if (imageKeys.length === 0) {
+ if (images.length === 0) {
toast.error(t("noPhoto"));
return;
}
@@ -83,9 +83,9 @@ export function PhotoPostForm({ onClose }: PhotoPostFormProps) {
createMutation.mutate({
petId: activePetId,
caption: caption.trim() || null,
- imageKeys,
+ images,
});
- }, [activePetId, imageKeys, caption, createMutation, t]);
+ }, [activePetId, images, caption, createMutation, t]);
if (!activePetId) {
return (
@@ -100,7 +100,7 @@ export function PhotoPostForm({ onClose }: PhotoPostFormProps) {
{/* Multi-image upload zone */}
{/* Caption textarea */}
@@ -134,7 +134,7 @@ export function PhotoPostForm({ onClose }: PhotoPostFormProps) {