Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-remark-images): set wrapperStyle as a function to enable …
…dynamic css (#12060) ## Description User can provide a function as `wrapperStyle` which receives the `fluidResult` containing image information like the `aspectRatio` which allows dynamic and customizable image styling <!-- Have any questions? Check out the contributing docs at https://gatsby.app/contribute, or ask in this Pull Request and a Gatsby maintainer will be happy to help :) --> ## Old Description <!-- Write a brief description of the changes introduced by this PR --> Providing the new option `addAspectRatio` to the package settings, this PR will add the already available aspect ratio of the image to the wrapperStyle as flex property. Which allows images of different aspect ratios to adjust their sizes to match heights of siblings in a `display: flex;` container like this  instead of this  live example: https://www.gaiama.org/15 (you'll have to scroll a little bit for images with differing aspect ratios) I'm of course open to feedback and changes or other approaches 👍 IMHO it's a small change no one would ever notice not using it, but would help me a lot and maybe even open others the possibility of (in my opinion) beautiful inline image galleries 😀 I thought about a plugin running after `gatsby-remark-images` as well, yet that would mean recalculating the aspect ratios which are already present here. By the way I'm currently running a small custom remark-plugin afterwards to wrap multiple images in the same paragraph in a flex enabled container. Link to old version where I overcomplicated things a little 🤦♂️https://github.com/GaiAma/gaiama.org/blob/master/packages/gatsby-remark-wrap-images/index.js so lines 31-41 is not necessary anymore.. new approach will be to just wrap images in a div with a customizable class, I could package that one up of course Wish y'all a great monday 🙏 Co-authored-by: Ward Peeters <[email protected]>
- Loading branch information