Hi,
After much effort, I have my Gatsby App deployed on Netlify and almost working with Prismic Previews.
However, I have a feature built into my application that is being broken by the way Prismic Previews render gatsby images. For some reason, the rendered html of the Gatsby Image in the PrismicPreview is fundamentally different from that of a production build.
Notably, here is what the production gatsby-image dom structure looks like (simplified for clarity)
<div data-gatsby-image-wrapper class="gatsby-image-wrapper my-class">
<div aria-hidden="true" style="padding-top: 177.778%;"></div>
<picture>{<source> image data}</picture>
<picture>{<source> displayed image data}</picture>
</div>
Here, the padding-bottom css styling is maintaining the aspect ratio of the image. Notably, I am using ArtDirection for this GatsbyImage. What I found, is that ArtDirection only supports images that have the same aspect ratio. So I developed a component that calculates the different aspect ratio's of each of my ArtDirectedImages, and applies styling to the aria-hidden
padding-bottom
to display the correct aspect ratio. Works great.
However, for reasons I don't fully understand, this is how the GatsbyImage is rendered when viewing the site in PrismicPreview mode:
<div data-gatsby-image-wrapper class="gatsby-image-wrapper gatsby-image-wrapper-constrained my-class">
<div style="max-width: 1080px; display: block;"><img alt="" role="presentation" aria-hidden="true" src="data:image/svg+xml;... height='1920' width='1080'..." style="max-width: 100%; display: block; position: static;"></div>
<div aria-hidden="true" data-placeholder-image="" style="opacity: 0; transition: opacity 500ms linear 0s; object-fit: cover;"></div>
<picture>{<source> displayed image}</picture>
</div>
This completely breaks what I have going for the ArtDirectedImages, and makes it impossible for my client to properly preview image changes in this section.
I guess as a start, can someone help me understand why there is this divergence in the way the GatsbyImage component is rendered in Previews vs. not? Note that there is even an added class on the wrapper of gatsby-image-wrapper-constrained
. Any help is much appreciated!