diff --git a/src/components/GalleryImage/GalleryImage.js b/src/components/GalleryImage/GalleryImage.js index 79fc144..a52164e 100644 --- a/src/components/GalleryImage/GalleryImage.js +++ b/src/components/GalleryImage/GalleryImage.js @@ -20,6 +20,7 @@ import { getVibrant, getHelmetSafeBodyStyle, hasName, + getCanonicalSize, } from "../../utils"; import MetadataItem from "./MetadataItem"; @@ -35,7 +36,7 @@ const logKeyShortcut = (keyCode) => { }; const GalleryImage = ({ data, pageContext }) => { - const image = data.allFile.edges[0].node; + const image = data.file; const ar = getAspectRatio(image); const [zoom, setZoom] = useState(false); @@ -72,13 +73,13 @@ const GalleryImage = ({ data, pageContext }) => { const name = getName(image); const { meta, dateTaken: dt } = getMeta(image); - // const locationString = meta.City; let locationString; if (meta.City || meta.State || meta.Location) { const location = [meta.Location, meta.City, meta.State].filter(Boolean); locationString = location.join(", "); } const vibrant = getVibrant(image, true); + const canonicalSize = getCanonicalSize(image); const orientationClasses = ar > 1 @@ -140,29 +141,33 @@ const GalleryImage = ({ data, pageContext }) => {
setZoom((_zoom) => !_zoom)} style={{ - maxWidth: zoom - ? "unset" - : `calc(max(calc(100vh - ${verticalPad}), 500px) * ${ar})`, - width: zoom - ? `max(calc(100vw - 16px), calc(100vh * ${ar}))` - : "unset", - // minHeight: zoom ? "100vh" : "unset", + maxWidth: `calc(max(calc(100vh - ${verticalPad}), 500px) * ${ar})`, }} > - setZoom((_zoom) => !_zoom)} - /> + {zoom ? ( + {name} + ) : ( + + )}
{ export const query = graphql` query GalleryImage($imageFilename: String) { - allFile( - filter: { - sourceInstanceName: { eq: "gallery" } - base: { eq: $imageFilename } + file(base: { eq: $imageFilename }) { + base + publicURL + childImageSharp { + fluid { + aspectRatio + } + gatsbyImageData( + layout: CONSTRAINED + placeholder: DOMINANT_COLOR + quality: 90 + ) } - ) { - edges { - node { - base - publicURL - childImageSharp { - fluid { - aspectRatio - } - gatsbyImageData( - layout: CONSTRAINED - # placeholder: BLURRED - placeholder: DOMINANT_COLOR - # placeholder: TRACED_SVG - height: 2160 - quality: 90 - ) + fields { + imageMeta { + dateTaken + meta { + Make + Model + ExposureTime + FNumber + ISO + DateTimeOriginal + CreateDate + ShutterSpeedValue + ApertureValue + FocalLength + LensModel + ObjectName + Caption + Location + City + State } - fields { - imageMeta { - dateTaken - meta { - Make - Model - ExposureTime - FNumber - ISO - DateTimeOriginal - CreateDate - ShutterSpeedValue - ApertureValue - FocalLength - LensModel - ObjectName - Caption - Location - City - State - } - vibrant { - ...VibrantColors - } - } + vibrant { + ...VibrantColors } } } diff --git a/src/utils.js b/src/utils.js index 0663e8a..aa28bda 100644 --- a/src/utils.js +++ b/src/utils.js @@ -13,6 +13,11 @@ export const hasName = (image) => Boolean(getMeta(image)?.meta?.ObjectName); export const getAspectRatio = (image) => image.childImageSharp.fluid.aspectRatio; +export const getCanonicalSize = (image) => ({ + height: image.childImageSharp.gatsbyImageData.height, + width: image.childImageSharp.gatsbyImageData.width, +}); + export const getRgba = (palette, alpha) => `rgba(${palette[0]}, ${palette[1]}, ${palette[2]}, ${alpha || 1})`;