11 Display Embedded Media
Pressbooks
Pressbooks allows you to include a variety of embedded media in your book. You have likely encountered content like this all over the web: YouTube videos in blog posts, Tweets embedded in news articles, or timelines and simulations on an educational site. Many of the same kinds of media or interactive content can be included in your book, allowing your readers to watch videos, view interactive maps, engage with simulations, and more without ever leaving your book.
Display Uploaded Media in Your Book
You can upload some media files, like images and reasonably sized audio files, directly to your book’s media library. Media from your book’s media library can be embedded using the ‘Add’ Media’ button located just above the visual editor. The following is a partial list of supported media file types (your network may allow you to upload additional file types):
Images | Audio | Video | Files |
|
|
|
|
Embed Content via oEmbed
You can automatically embed media from a variety of providers (like YouTube, Twitter, Vimeo, TED, Flickr, Reddit, TikTok, Spotify, and more) which support the oEmbed specification. To embed content from a supported oembed provider:
- Copy the URL of the video, audio, or other media (i.e.
https://www.youtube.com/watch?v=hrcrFJVgbbs
) - Paste the URL onto its own line into the Visual editor
- Click Save
The URL you pasted in step two, should be automatically replaced by the embedded content in the visual editor. After you save the chapter or post, the content will display in the webbook and can be seen by readers if the book is made public.
Embed iframes
Pressbooks restricts the embedding on iframes from most other sites for security reasons. We will allow iframes to be embedded from the following providers, however:
To embed an iframe from a source that has been permitted for your network:
- Copy the source object’s <iframe> embed code (this is usually available in the sharing options of the media on its source website)
- Switch to the Text editor in Pressbooks and paste the iframe code you copied in step 1.
- Click Save
If the source comes from a permitted domain, and you have copied in the source object’s <iframe> embed code, the video should then appear in your visual editor and webbook. If you’re unable to embed an iframe from a source because it isn’t allowed for your network, consider simply adding a hyperlink to the resource.
Use Embed and Media Shortcodes
Pressbooks supports two shortcodes, Embed and Media. The embed shortcode is most useful when you’re drafting content outside of Pressbooks (in a word processor, for example) but want to import it later. Using the embed shortcode signals to Pressbooks that there’s an embedded video and not just a regular link in your book. Here’s a sample embed shortcode: [embed]https://www.youtube.com/watch?v=hrcrFJVgbbs[/embed]
The media shortcode allows you to embed an externally hosted media file (like an image) and includes an optional parameter which will let you define a caption for that embedded media element. Here’s a sample media shortcode (with caption) for a photograph of the Hagia Sophia which is hosted on Wikimedia:
Insert H5P Activities
Many Pressbooks networks designed for educational publishing include an integration with H5P, a powerful open source tool that allows you to insert interactive quizzes and other learning activities directly into your webbook. Learn more about creating H5P activities in your book.
Embedded Media in Exports
Not all embedded media can be displayed in ebook and PDF files. Pressbooks attempts to provide a graceful fallback for any embedded content which cannot be displayed with its proper functionality in any of our export formats. This fallback consists of an inserted message that is populated with information available in the system (may include a title, thumbnail, the kind of media, etc.) and provides the reader with a link to the webbook version of the chapter so they can view the missing element (print readers will see a short URL that they can type into a browser).