From 38c224f10a16dd117ca7a3be31b5c3840203ca03 Mon Sep 17 00:00:00 2001 From: Danny Wilson Date: Tue, 13 Feb 2018 17:00:41 -0400 Subject: [PATCH 1/2] Allow specifying which html tag will be used for gatsby-image wrappers --- packages/gatsby-image/src/index.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/gatsby-image/src/index.js b/packages/gatsby-image/src/index.js index 7100366fd0685..94b485d52662f 100644 --- a/packages/gatsby-image/src/index.js +++ b/packages/gatsby-image/src/index.js @@ -187,6 +187,7 @@ class Image extends React.Component { sizes, resolutions, backgroundColor, + Tag, } = convertProps(this.props) let bgColor @@ -207,7 +208,7 @@ class Image extends React.Component { // The outer div is necessary to reset the z-index to 0. return ( -
-
{/* Preserve the aspect ratio. */} -
-
-
+ + ) } @@ -327,7 +328,7 @@ class Image extends React.Component { // The outer div is necessary to reset the z-index to 0. return ( -
-
-
-
+ + ) } @@ -421,6 +422,7 @@ class Image extends React.Component { Image.defaultProps = { fadeIn: true, alt: ``, + Tag: `div`, } Image.propTypes = { @@ -440,6 +442,7 @@ Image.propTypes = { position: PropTypes.string, backgroundColor: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), onLoad: PropTypes.func, + Tag: PropTypes.string, } export default Image From 2486ade0da5587611fbbc8748884e1cef2ab0be5 Mon Sep 17 00:00:00 2001 From: Danny Wilson Date: Tue, 13 Feb 2018 17:11:30 -0400 Subject: [PATCH 2/2] Update gatsby-image README.md to include new Tag prop --- packages/gatsby-image/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-image/README.md b/packages/gatsby-image/README.md index c51319822b3c6..0bba09e5b3ec9 100644 --- a/packages/gatsby-image/README.md +++ b/packages/gatsby-image/README.md @@ -7,7 +7,7 @@ Gatsby's GraphQL queries. It combines [Gatsby's native image processing](https://image-processing.gatsbyjs.org/) capabilities with advanced image loading techniques to easily and completely optimize image loading for your sites. `gatsby-image` uses -[gatsby-plugin-sharp](https://www.gatsbyjs.org/packages/gatsby-plugin-sharp/) +[gatsby-plugin-sharp](https://www.gatsbyjs.org/packages/gatsby-plugin-sharp/) to power its image transformations. _Warning: gatsby-image is **not** a drop-in replacement for ``. It's @@ -250,15 +250,16 @@ prop. e.g. `` | `fadeIn` | `bool` | Defaults to fading in the image on load | | `title` | `string` | Passed to the `img` element | | `alt` | `string` | Passed to the `img` element | -| `className` | `string\|object` | Passed to the wrapper div. Object is needed to support Glamor's css prop | -| `outerWrapperClassName` | `string\|object` | Passed to the outer wrapper div. Object is needed to support Glamor's css prop | -| `style` | `object` | Spread into the default styles in the wrapper div | +| `className` | `string\|object` | Passed to the wrapper element. Object is needed to support Glamor's css prop | +| `outerWrapperClassName` | `string\|object` | Passed to the outer wrapper element. Object is needed to support Glamor's css prop | +| `style` | `object` | Spread into the default styles in the wrapper element | | `position` | `string` | Defaults to `relative`. Pass in `absolute` to make the component `absolute` positioned | | `backgroundColor` | `string\|bool` | Set a colored background placeholder. If true, uses "lightgray" for the color. You can also pass in any valid color string. | | `onLoad` | `func` | A callback that is called when the full-size image has loaded. | +| `Tag` | `string` | Which HTML tag to use for wrapping elements. Defaults to `div`. | ## Image processing arguments -[gatsby-plugin-sharp](/packages/gatsby-plugin-sharp) supports many additional arguments for transforming your images like +[gatsby-plugin-sharp](/packages/gatsby-plugin-sharp) supports many additional arguments for transforming your images like `quality`,`sizeByPixelDensity`,`pngCompressionLevel`,`cropFocus`,`greyscale` and many more. See its documentation for more. ## Some other stuff to be aware of