35 lines
794 B
TypeScript
35 lines
794 B
TypeScript
import { Photo } from "./models/photo";
|
|
|
|
export function initPhoto(
|
|
image: any,
|
|
description: string,
|
|
model: string,
|
|
filename: string,
|
|
): Photo {
|
|
return {
|
|
src: image.default.src,
|
|
filename: filename,
|
|
format: image.default.format,
|
|
height: image.default.height,
|
|
width: image.default.width,
|
|
description: description,
|
|
model: model,
|
|
} as Photo;
|
|
}
|
|
|
|
export function initPhotos(images: any): Photo[] {
|
|
return Object.values(images)
|
|
.map((img: any) => {
|
|
const splited = img.default.src.split("/");
|
|
const filename: string = splited[splited.length - 1].split("?")[0];
|
|
|
|
return initPhoto(
|
|
img,
|
|
"Aucune description disponible",
|
|
"Aucun model d'appareil photo disponible",
|
|
filename,
|
|
);
|
|
})
|
|
.reverse();
|
|
}
|