You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/gatsby-image/README.md
+4-24
Original file line number
Diff line number
Diff line change
@@ -225,6 +225,7 @@ Their fragments are:
225
225
-`GatsbyImageSharpFluid_withWebp`
226
226
-`GatsbyImageSharpFluid_withWebp_noBase64`
227
227
-`GatsbyImageSharpFluid_withWebp_tracedSVG`
228
+
-`GatsbyImageSharpFluidLimitPresentationSize`
228
229
229
230
### gatsby-source-contentful
230
231
@@ -318,37 +319,16 @@ prop. e.g. `<Img fluid={fluid} />`
318
319
### Avoiding stretched images using the fluid type
319
320
320
321
As mentioned previously, images using the _fluid_ type are stretched to
321
-
match the container's width. In the case where the image's width is smaller than the available viewport, the image will stretch to match the container, potentially leading to unwanted problems and worsened image quality.
322
+
match the container's width and height. In the case where the image's width or height is smaller than the available viewport, the image will stretch to match the container, potentially leading to unwanted problems and worsened image quality.
322
323
323
-
To counter this edge case one could wrap the _Img_ component in order to set a better, for that case, `maxWidth`:
324
-
325
-
```jsx
326
-
constNonStretchedImage=props=> {
327
-
let normalizedProps = props
328
-
if (props.fluid&&props.fluid.presentationWidth) {
329
-
normalizedProps = {
330
-
...props,
331
-
style: {
332
-
...(props.style|| {}),
333
-
maxWidth:props.fluid.presentationWidth,
334
-
margin:"0 auto", // Used to center the image
335
-
},
336
-
}
337
-
}
338
-
339
-
return<Img {...normalizedProps} />
340
-
}
341
-
```
342
-
343
-
**Note:** The `GatsbyImageSharpFluid` fragment does not include `presentationWidth`.
344
-
You will need to add it in your graphql query as is shown in the following snippet:
324
+
To counter this edge case one could use the `GatsbyImageSharpFluidLimitPresentationSize` fragment to ask for additional presentation size properties.
0 commit comments