Skip to content

Media, Attachments, and Embeds

Images and Media

The Media block allows you to include images, GIFs, video and audio in your reports. If the file is in a supported format, it will be displayed inline in your report. To include an image, you can use dp.Media and pass the path.

dp.Media(file='./image.png')

In the following example, Datapane will attempt to display images in your report for viewers and allow users to download them.

import datapane as dp

report = dp.Report(
    dp.Media(file="./image.png", name="Image1", caption="Datapane in action!"),
)

report.save(path="image.html")

Attachments and Python objects

If you want to include static files like PDFs or Excel docs in your report, use the dp.Attachment block. You can also pass in a Python object directly. Once you upload the report, your users will be able to explore and download these attachments.

import datapane as dp

data_path = "./netflix_stock_data.csv"

vehicle_dict = {
  "brand": "Ford",
  "model": "Mustang",
  "year": 1964
}

report = dp.Report(
  dp.Attachment(file = data_path),
  dp.Attachment(vehicle_dict, name='vehicle_dict')
)

report.save(path='attachments-and-objects.html')

Embeds

The Embed block lets you embed content from other platforms e.g. Youtube, Spotify. This is how you'd use it:

import datapane as dp

report = dp.Report(
    dp.Embed(url='https://www.youtube.com/watch?v=_KS_yZBI71s&t')
)

report.save(path='embeds.html')

You don't need to use this block for simple embeds on TextReports like GIFs. For those, just use Markdown syntax i.e. ![](https://my-example-gif.gif)

Info

If you're trying to embed an iframe, you can wrap it in an HTML block.

Text and HTML