Media & Embeds
Media
¶
The Media block allows you to include images, GIFs, video and audio in your apps. If the file is in a supported format, it will be displayed inline in your app.
To include an image, you can use dp.Media
and pass the path.
Note
Supported video, audio and image formats depend on the browser used to view the report. MP3, MP4, and all common image formats are generally supported by modern browsers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
NPath
|
Path to a file to attach to the report (e.g. a JPEG image) |
required |
name |
BlockId
|
A unique name for the block to reference when adding text or embedding (optional) |
None
|
caption |
Optional[str]
|
A caption to display below the file (optional) |
None
|
label |
str
|
A label used when displaying the block (optional) |
None
|
¶
Simple image embed¶
In the following example, Datapane will display images in your app for viewers and allow users to download them.
Embed
¶
The Embed block lets you embed content from other platforms e.g. Youtube, Spotify.
Tip
If you're trying to embed an iframe
, you can wrap it in an HTML
block.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url |
str
|
The URL of the resource to be embedded |
required |
width |
int
|
The width of the embedded object (optional) |
960
|
height |
int
|
The height of the embedded object (optional) |
540
|
name |
BlockId
|
A unique name for the block to reference when adding text or embedding (optional) |
None
|
label |
str
|
A label used when displaying the block (optional) |
None
|
¶
Simple YouTube embed¶
You don't need to use this block for simple embeds, e.g. GIFs. For those, just use Markdown syntax i.e. ![](https://my-example-gif.gif)
Attachment
¶
If you want to include static files like PDFs or Excel docs in your app, use the dp.Attachment
block.
You can also pass in a Python object directly. Once you upload the app, your users will be able to explore and download these attachments.
Tip
To attach streamable / viewable video, audio or images, use the dp.Media
block instead
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Optional[Any]
|
A python object to attach to the report (e.g. a dictionary) |
None
|
file |
Optional[NPath]
|
Path to a file to attach to the report (e.g. a csv file) |
None
|
filename |
Optional[str]
|
Name to be used when downloading the file (optional) |
None
|
caption |
Optional[str]
|
A caption to display below the file (optional) |
None
|
name |
BlockId
|
A unique name for the block to reference when adding text or embedding (optional) |
None
|
label |
str
|
A label used when displaying the block (optional) |
None
|
Note
Either data
or file
must be provided