feat: store image metadata in sqlite and images on disk
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { asset } from "$fresh/runtime.ts";
|
||||
import * as CSS from "https://esm.sh/csstype@3.1.2";
|
||||
import { isLocalImage } from "@lib/string.ts";
|
||||
|
||||
interface ResponsiveAttributes {
|
||||
srcset: string;
|
||||
@@ -42,9 +41,11 @@ const Image = (
|
||||
style?: CSS.HtmlAttributes;
|
||||
},
|
||||
) => {
|
||||
const responsiveAttributes: ResponsiveAttributes = isLocalImage(props.src)
|
||||
? generateResponsiveAttributes(props.src, widths, "/api/images")
|
||||
: { srcset: "", sizes: "" };
|
||||
const responsiveAttributes = generateResponsiveAttributes(
|
||||
props.src,
|
||||
widths,
|
||||
"/api/images",
|
||||
);
|
||||
|
||||
return (
|
||||
<span
|
||||
@@ -64,7 +65,7 @@ const Image = (
|
||||
style={props.style}
|
||||
srcset={responsiveAttributes.srcset}
|
||||
sizes={responsiveAttributes.sizes}
|
||||
src={asset(props.src)}
|
||||
src={`/api/images?image=${asset(props.src)}`}
|
||||
width={props.width}
|
||||
height={props.height}
|
||||
class={props.class}
|
||||
|
||||
Reference in New Issue
Block a user