From db878b79f785ef9514efaa46e7cf8a45ab623f27 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sun, 21 Jan 2024 16:50:15 -0600 Subject: [PATCH] Add configuration option for hiding EXIF data --- README.md | 1 + src/photo/PhotoLarge.tsx | 11 ++++++++--- src/photo/image-response/PhotoImageResponse.tsx | 4 ++-- src/photo/index.ts | 11 +++++++++-- src/site/SiteChecklistClient.tsx | 10 ++++++++++ src/site/config.ts | 2 ++ 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8ebd954d..1968658b 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Installation - `NEXT_PUBLIC_PUBLIC_API = 1` enables public API available at `/api` - `NEXT_PUBLIC_HIDE_REPO_LINK = 1` removes footer link to repo - `NEXT_PUBLIC_HIDE_FILM_SIMULATIONS = 1` prevents Fujifilm simulations showing up in `/grid` sidebar +- `NEXT_PUBLIC_HIDE_EXIF_DATA = 1` hides EXIF data in photo details and OG images (potentially useful for portfolios, which don't focus on photography) - `NEXT_PUBLIC_GRID_ASPECT_RATIO = 1.5` sets aspect ratio for grid tiles (defaults to `1`—setting to `0` removes the constraint) - `NEXT_PUBLIC_OG_TEXT_ALIGNMENT = BOTTOM` keeps OG image text bottom aligned (default is top) diff --git a/src/photo/PhotoLarge.tsx b/src/photo/PhotoLarge.tsx index 935a3b55..466caf34 100644 --- a/src/photo/PhotoLarge.tsx +++ b/src/photo/PhotoLarge.tsx @@ -1,4 +1,9 @@ -import { Photo, photoHasCameraData, photoHasExifData, titleForPhoto } from '.'; +import { + Photo, + shouldShowCameraDataForPhoto, + shouldShowExifDataForPhoto, + titleForPhoto, +} from '.'; import SiteGrid from '@/components/SiteGrid'; import ImageLarge from '@/components/ImageLarge'; import { clsx } from 'clsx/lite'; @@ -92,7 +97,7 @@ export default function PhotoLarge({ {tags.length > 0 && } - {showCamera && photoHasCameraData(photo) && + {showCamera && shouldShowCameraDataForPhoto(photo) &&
} )} {renderMiniGrid(<> - {photoHasExifData(photo) && + {shouldShowExifDataForPhoto(photo) &&
  • {photo.focalLengthFormatted} diff --git a/src/photo/image-response/PhotoImageResponse.tsx b/src/photo/image-response/PhotoImageResponse.tsx index 5874e4dd..fcc28897 100644 --- a/src/photo/image-response/PhotoImageResponse.tsx +++ b/src/photo/image-response/PhotoImageResponse.tsx @@ -1,4 +1,4 @@ -import { Photo, photoHasExifData } from '..'; +import { Photo, shouldShowExifDataForPhoto } from '..'; import { AiFillApple } from 'react-icons/ai'; import ImageCaption from './components/ImageCaption'; import ImagePhotoGrid from './components/ImagePhotoGrid'; @@ -30,7 +30,7 @@ export default function PhotoImageResponse({ height, ...OG_TEXT_BOTTOM_ALIGNMENT && { imagePosition: 'top' }, }} /> - {photoHasExifData(photo) && + {shouldShowExifDataForPhoto(photo) && {photo.make === 'Apple' &&
    diff --git a/src/photo/index.ts b/src/photo/index.ts index a03b81ba..f7806cf6 100644 --- a/src/photo/index.ts +++ b/src/photo/index.ts @@ -1,4 +1,5 @@ import { FilmSimulation } from '@/simulation'; +import { SHOW_EXIF_DATA } from '@/site/config'; import { ABSOLUTE_PATH_FOR_HOME_IMAGE } from '@/site/paths'; import { formatDateFromPostgresString } from '@/utility/date'; import { @@ -221,14 +222,20 @@ export const dateRangeForPhotos = ( return { start, end, description }; }; -export const photoHasCameraData = (photo: Photo) => +const photoHasCameraData = (photo: Photo) => photo.make && photo.model; -export const photoHasExifData = (photo: Photo) => +const photoHasExifData = (photo: Photo) => photo.focalLength || photo.focalLengthIn35MmFormat || photo.fNumberFormatted || photo.isoFormatted || photo.exposureTimeFormatted || photo.exposureCompensationFormatted; + +export const shouldShowCameraDataForPhoto = (photo: Photo) => + SHOW_EXIF_DATA && photoHasCameraData(photo); + +export const shouldShowExifDataForPhoto = (photo: Photo) => + SHOW_EXIF_DATA && photoHasExifData(photo); diff --git a/src/site/SiteChecklistClient.tsx b/src/site/SiteChecklistClient.tsx index 6ea9004e..43a86929 100644 --- a/src/site/SiteChecklistClient.tsx +++ b/src/site/SiteChecklistClient.tsx @@ -35,6 +35,7 @@ export default function SiteChecklistClient({ hasDomain, showRepoLink, showFilmSimulations, + showExifInfo, isProModeEnabled, isGeoPrivacyEnabled, isPriorityOrderEnabled, @@ -317,6 +318,15 @@ export default function SiteChecklistClient({ simulations showing up in /grid sidebar: {renderEnvVars(['NEXT_PUBLIC_HIDE_FILM_SIMULATIONS'])} + + Set environment variable to {'"1"'} to hide EXIF data: + {renderEnvVars(['NEXT_PUBLIC_HIDE_EXIF_DATA'])} + 0, showRepoLink: SHOW_REPO_LINK, showFilmSimulations: SHOW_FILM_SIMULATIONS, + showExifInfo: SHOW_EXIF_DATA, isProModeEnabled: PRO_MODE_ENABLED, isGeoPrivacyEnabled: GEO_PRIVACY_ENABLED, isPriorityOrderEnabled: PRIORITY_ORDER_ENABLED,