Skip to content

feat(gatsby-image): Whitelist crossorigin prop for pass through to img tag#9758

Merged
wardpeet merged 4 commits intogatsbyjs:masterfrom
wconnorwalsh:topics/add-crossorigin-to-gatsby-image
Mar 15, 2019
Merged

feat(gatsby-image): Whitelist crossorigin prop for pass through to img tag#9758
wardpeet merged 4 commits intogatsbyjs:masterfrom
wconnorwalsh:topics/add-crossorigin-to-gatsby-image

Conversation

@wconnorwalsh
Copy link
Copy Markdown
Contributor

The crossorigin prop is occasionally needed on the root img tag to enable CORS requests.

This PR passes that prop from Image to img, just as it already passes the alt and title props.

@wconnorwalsh wconnorwalsh changed the title [gatsby-image] Whitelist crossorigin prop for pass through to img tag feat(gatsby-image) Whitelist crossorigin prop for pass through to img tag Nov 7, 2018
@wconnorwalsh wconnorwalsh changed the title feat(gatsby-image) Whitelist crossorigin prop for pass through to img tag feat(gatsby-image): Whitelist crossorigin prop for pass through to img tag Nov 7, 2018
Copy link
Copy Markdown
Contributor

@DSchau DSchau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure - this seems reasonable.

More general question, since you just dived into the code. Does it make sense to stop maintaining this whitelist of valid image props, and rather be a little less selective and pluck the props we need, and pass others down appropriately?

In other words, there are several HTML attributes valid on the img tag and it may make more sense to just pass down and serialize appropriately, rather than explicitly handling each of these cases.

@wardpeet wardpeet self-assigned this Jan 11, 2019
@wardpeet
Copy link
Copy Markdown
Contributor

wardpeet commented Mar 15, 2019

lets revisit this in gatsby v3 where we can do lots of optimisations. I'll be merging this one

Copy link
Copy Markdown
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread packages/gatsby-image/src/__tests__/index.js
@wardpeet
Copy link
Copy Markdown
Contributor

@wconnorwalsh thank you for your patience! This went way to long! thanks for adding this feature!

@wardpeet wardpeet merged commit 7684b4f into gatsbyjs:master Mar 15, 2019
raffishquartan pushed a commit to raffishquartan/gatsby that referenced this pull request Apr 28, 2026
…`img` tag (gatsbyjs#9758)

* Whitelisted `crossorigin` prop for pass through to `img` tag

* Updated typings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants