io.display.image

A chart or a photo, right in the step.

io.display.image shows a picture in a page or in a step of an action. It takes any URL the browser can load. Show a chart before someone decides, or the photo a customer uploaded. It only displays and returns nothing.

The simplest one

The whole action file, and roughly what your team sees when it runs.

src/actions/photos/reviewPhotoAction.ts
import { app } from '../../app';
import { getSignedUrl } from '../../storage';
export const reviewPhotoAction = app.defineAction({
name: 'Review photo',
handler: async ({ io }) => {
await io.display.image('Uploaded photo', {
url: await getSignedUrl('photos/42.jpg'),
size: 'medium',
});
},
});
The code. One call in an action, the whole file.
tools.example.com/actions/photos/review_photo

Review photo

Uploaded photo
Continue
In the browser. Roughly what your team sees. Your theme decides the details.

What you can set

The settings you will reach for most, each with the line of code that turns it on.

url: await getSignedUrl(fileKey)

Any image URL. A chart from a chart service or a signed link to an uploaded file. If the browser can load it, it shows.

size: 'medium'

Four sizes. Pick how tall the picture may get: thumbnail, small, medium or large.

io.display.image('Store front', { url })

Full width by default. Leave out the size and the picture is as wide as there is room for.

alt: 'Coffee beans on a scale'

Text for when it does not load. Screen readers read the alt text. It also shows when the image does not load. Without it, the label is used.

io.display.image(null, { url })

A heading or none. The label is the heading above the picture. Pass null to show the picture alone.

photo: io.display.image('Photo', { url }),

Next to a question. In io.group it sits next to inputs, such as a photo right above the question whether to approve it.

Write your first tool today.

An async function, a few await calls, and the form is in the browser.

AwaitIO is free for small teams, made possible by companies and people who sponsor it.