Skip to content

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 ar.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

A ath to a file to attach to the report (e.g. a JPEG image)

required
name str | None

A unique name for the block to reference when adding text or embedding (optional)

None
caption str | None

A caption to display below the file (optional)

None
label str | None

A label used when displaying the block (optional)

None

Simple Image Embed

In the following example, Arakawa will display images in your app for viewers and allow users to download them.

ar.Media(file="./image.png", name="Image1", caption="Arakawa in action!")

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

A URL of the resource to be embedded

required
width int

A width of the embedded object (optional)

960
height int

A height of the embedded object (optional)

540
name str | None

A unique name for the block to reference when adding text or embedding (optional)

None
label str | None

A label used when displaying the block (optional)

None

Simple YouTube Embed

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

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 ar.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 ar.Media block instead

Parameters:

Name Type Description Default
data Any

A python object to attach to the report (e.g. a dictionary)

None
file NPath | None

A path to a file to attach to the report (e.g. a csv file)

None
filename str | None

A name to be used when downloading the file (optional)

None
caption str | None

A caption to display below the file (optional)

None
name str | None

A unique name for the block to reference when adding text or embedding (optional)

None
label str | None

A label used when displaying the block (optional)

None

Note

Either data or file must be provided

Simple Attachment

data_path = "./netflix_stock_data.csv"

ar.Attachment(file=data_path)

Python Object Attachment

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

ar.Attachment(vehicle_dict, name="vehicle_dict")

Multiple Attachments

data_path = "./netflix_stock_data.csv"

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

ar.Group(
    ar.Attachment(file=data_path), ar.Attachment(vehicle_dict, name="vehicle_dict")
)