Importing Media Content
“Media content” is a broad term that generally includes images, videos, documents and files that are displayed on your website. For Gatsby sites, you have multiple options for importing media content depending on the type:
- Image graphics can be imported with Webpack and queried with GraphQL.
- Images can also be included from the
- SVG content can be embedded into JSX. Here’s a handy JSX converter.
- SVG can be included in
imgtags or CSS backgrounds. SVG Tips from CSS Tricks.
- For PDF files, we recommend embedding an image of the PDF with alternative text, and providing a link to download a tagged PDF.
Like images, video assets present many options and requirements for cross-browser support. Learn about video embeds on the Gatsby docs page on working with video section.
<canvas> element provides a space for 2-dimensional drawing in a web environment. In Gatsby and React, it may help to include a library like react-konva or one of the comparison libraries to cut down on boilerplate and make drawing easier.
Using canvas and/or WebGL may require modifying your Webpack config. Do you have experience with making this work in your Gatsby site? Contribute to the docs by adding more details to this page.
Edit this page on GitHub