Fix category index thumbnail
This commit is contained in:
@@ -23,7 +23,7 @@ const categories = await getAllCategories(settings);
|
||||
<a href={getCategoryRoute(settings.photo, category)} class="group relative block w-[70%] overflow-hidden rounded-2xl shadow-md">
|
||||
<div>
|
||||
<Image
|
||||
src={getImageUrl(category.thumbnail.url)}
|
||||
src={category.thumbnail.url}
|
||||
alt={category.title}
|
||||
width={category.thumbnail.width}
|
||||
height={category.thumbnail.height}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createDirectusConnection } from "@/lib/directus";
|
||||
import { print } from "graphql";
|
||||
import getCategories from '@/graphql/photos/getCategories.graphql';
|
||||
import getCategory from '@/graphql/photos/getCategory.graphql';
|
||||
import { getImageSize } from "@/lib/images";
|
||||
import { getImageSize, getImageUrl } from "@/lib/images";
|
||||
|
||||
export async function getAllCategories(settings: GlobalSettings): Promise<PhotoAlbumCategory[]> {
|
||||
const client = await createDirectusConnection();
|
||||
@@ -11,15 +11,15 @@ export async function getAllCategories(settings: GlobalSettings): Promise<PhotoA
|
||||
let categories: PhotoAlbumCategory[] = [];
|
||||
|
||||
result["Photo_Categories"].forEach((photoCategoryRecord: any) => {
|
||||
const imageSize =
|
||||
getImageSize(photoCategoryRecord["thumbnail"]["width"], photoCategoryRecord["thumbnail"]["height"], 1.5);
|
||||
const imageSize = getImageSize(photoCategoryRecord["thumbnail"]["width"],
|
||||
photoCategoryRecord["thumbnail"]["height"], 1.5);
|
||||
|
||||
categories.push({
|
||||
id: photoCategoryRecord["id"],
|
||||
title: photoCategoryRecord["title"],
|
||||
url: photoCategoryRecord["url"],
|
||||
thumbnail: {
|
||||
url: photoCategoryRecord["thumbnail"]["filename_disk"],
|
||||
url: getImageUrl(photoCategoryRecord["thumbnail"]["filename_disk"]),
|
||||
width: imageSize.width,
|
||||
height: imageSize.height
|
||||
}
|
||||
|
||||
@@ -97,6 +97,21 @@ export async function getPage(settings: GlobalSettings, route: string): Promise<
|
||||
const allCategories = await getAllCategories(settings);
|
||||
const lastCategory = allCategories[0];
|
||||
|
||||
const resizedThumbnail = getImageSize(lastCategory.thumbnail.width, lastCategory.thumbnail.height, 0.756);
|
||||
|
||||
const thumbnail = await getImage({
|
||||
src: lastCategory.thumbnail.url,
|
||||
width: resizedThumbnail.width,
|
||||
height: resizedThumbnail.height,
|
||||
format: "jpeg"
|
||||
});
|
||||
|
||||
lastCategory.thumbnail = {
|
||||
url: `${settings.website.domainName}${thumbnail.src}`,
|
||||
width: resizedThumbnail.width,
|
||||
height: resizedThumbnail.height
|
||||
}
|
||||
|
||||
return {
|
||||
route: route,
|
||||
pageType: "PhotoCategoryIndex",
|
||||
|
||||
Reference in New Issue
Block a user