This demo uses gatsby-remark-images
.
Order of plugins in your gatsby-config.js matters. Please add gatsby-remark-image-attributes
after gatsby-remark-images
or any other image processing plugins!
![no attributes](./gatsby-logo.png 'No attributes, here')
To use CSS properties like box-shadow
, add them to the title!
![test](./gatsby-logo.png '#box-shadow=0px 0px 10px 2px rgb(2, 2, 2);width=150px')
gatsby-remark-image-attributes
wraps the result of other image processing plugins, aiming to reach body
as the wrapper's offsetParent
. Your styleAttributes
will be set on that wrapper, not the <img>
.
Compare the offsetParent
s of these two images to see the difference:
This is the ribbon in the upper-right corner of this page:
![fork me on github](./fmog.png '#position=absolute;right=0;top=0;width=150px;height=150px')
This plugin generates <img>
tags and all browsers support SVG in <img>
Elements.
![svg](./gatsby-logo.svg '#height=150px;filter=hue-rotate(-282deg) brightness(1.5) drop-shadow(2px 4px 6px black)')
works ![gatsby](./gatsby-logo.png '#width=32px;vertical-align=text-bottom') inline ![gatsby](./gatsby-logo.png '#width=32px;vertical-align=middle'), too ![gatsby](./gatsby-logo.png '#width=32px;vertical-align=text-top')
works inline , too
* or ![gatsby](./gatsby-logo.png'#width=24px;vertical-align=middle')
* in ![gatsby](./gatsby-logo.png '#width=24px;vertical-align=middle;margin-top=10px;margin-bottom=10px')
* lists ![gatsby](./gatsby-logo.png '#width=24px;vertical-align=middle')
Set the plugin's dataAttributes
option to true
to enable data- attributes.
![gatsby](./gatsby-logo.png '#some=value with spaces;another=without;width=32px;vertical-align=middle')
'Inspect' this Element ⇒
to see data-some
and data-another
on it!
Unlike the styleAttributes, dataAttributes are always set on the <img>
Element, never on the wrapper.
Titles without key=value;
pairs behave according to the CommonMark standard; even when they start with a #
.
![no attributes](./gatsby-logo.png '#this is just a title, despite starting with a #')
To add an actual title=""
attribute to the <img>
, add an image attribute with key: title
.
![title from attribute](./gatsby-logo.png '#width=64px;some=data;title=This has a title from image attributes')