Display photos in details panel (#100)

This commit is contained in:
czifumasa
2022-05-13 22:15:40 +02:00
committed by GitHub
parent d30c038406
commit 4ca0025438
7 changed files with 224 additions and 9 deletions

View File

@@ -118,7 +118,8 @@ function calcDateDifferenceInYears(
const startYear = firstDateObject.getUTCFullYear();
let yearDiff = secondDateObject.getUTCFullYear() - startYear;
let monthDiff = secondDateObject.getUTCMonth() - firstDateObject.getUTCMonth();
let monthDiff =
secondDateObject.getUTCMonth() - firstDateObject.getUTCMonth();
if (monthDiff < 0) {
yearDiff--;
monthDiff += 12;

View File

@@ -192,10 +192,10 @@ export function normalizeGedcom(gedcom: JsonGedcomData): JsonGedcomData {
return sortSpouses(sortChildren(gedcom));
}
const IMAGE_EXTENSIONS = ['.jpg', '.png', '.gif'];
const IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif'];
/** Returns true if the given file name has a known image extension. */
function isImageFile(fileName: string): boolean {
export function isImageFile(fileName: string): boolean {
const lowerName = fileName.toLowerCase();
return IMAGE_EXTENSIONS.some((ext) => lowerName.endsWith(ext));
}
@@ -282,3 +282,12 @@ export function getName(person: GedcomEntry): string | undefined {
const name = notMarriedName || names[0];
return name?.data.replace(/\//g, '');
}
export function getFileName(fileEntry: GedcomEntry): string | undefined {
const fileTitle = fileEntry?.tree.find((entry) => entry.tag === 'TITL')?.data;
const fileExtension = fileEntry?.tree.find((entry) => entry.tag === 'FORM')
?.data;
return fileTitle && fileExtension && fileTitle + '.' + fileExtension;
}