Media, Attachments, and Embeds

Images and Media

Requires Datapane version 0.13+
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.
1
dp.Media(file='./image.jpeg')
Copied!
In the following example, Datapane will attempt to display images in your report for viewers and allow users to download them.
1
import datapane as dp
2
3
report = dp.Report(
4
dp.Media(file="./image.jpeg", name="Plot 1", caption="A pretty image"),
5
)
6
report.upload(name='Image Sample')
Copied!

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.
1
import datapane as dp
2
3
myfilepath = "./financial_model.xlsx"
4
5
thisdict = {
6
"brand": "Ford",
7
"model": "Mustang",
8
"year": 1964
9
}
10
11
dp.Report(
12
dp.Attachment(file = myfilepath),
13
dp.Attachment(thisdict, name='thisdict')
14
).upload(name='json')
Copied!

Embeds

The Embed block lets you embed content from other platforms e.g. Youtube, Spotify. This is how you'd use it:
Python
Text Report
1
import datapane as dp
2
3
dp.Report(
4
dp.Embed(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ')
5
).upload(name='Embex example')
Copied!
1
```datapane
2
block: embed
3
url: https://www.youtube.com/watch?v=dQw4w9WgXcQ
4
caption: Youtube video
5
```
Copied!
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)
If you're trying to embed an iframe, you can wrap it in an HTML block.
Last modified 2mo ago