Skip to content
Block Kit for React
Esc
↑↓navigate↵open⌘Jpreview
On this page

Image block

A standalone image with an optional title row.

image renders a single image, from either a public URL (image_url) or a file in the workspace (slack_file): exactly one of the two is required. Use it to show a screenshot, photo, or diagram inline in a message, modal, or App Home surface. See Limits for its field lengths.

Your AppAPP
I love tacos
delicious tacos

Fields

PropType
typestring

Always image.

Typestring
image_url?string

A public URL to a GIF, JPEG, PNG, or BMP. Mutually exclusive with slack_file.

Typestring
slack_file?{ id?: string; url?: string }

A file already uploaded to Slack, referenced by id or internal url. Mutually exclusive with image_url.

Type{ id?: string; url?: string }
alt_textstring

A plain-text summary for screen readers. Doesn't render on screen.

Typestring
title?PlainTextElement

A caption shown above the image. Plain text only; mrkdwn isn't supported.

TypePlainTextElement
block_id?string

A unique identifier, up to 255 characters.

Typestring

Examples

Without a title

Your AppAPP
delicious tacos

With no title, Slack still reserves the title row’s height for the expand caret, so the image sits at the same vertical offset either way.

Hovering the image shows Slack’s actions in its top-right corner: Open in new window, and a More actions menu with Copy link (copies the image URL) and Hide image (collapses it as the caret does). They stay in the page: none of them calls onAction.

With a title

Your AppAPP
I love tacos
delicious tacos

Slack files

Your AppAPP

This preview has no resolvers.slackFile, so it renders the alt-text fallback. With one, the file shows like an image_url, at most 400 x 400:

<BlockKitProvider
  resolvers={{
    slackFile: (file) => (file.id ? { url: `/api/slack/files/${file.id}` } : undefined),
  }}
>

Downloading a Slack file takes the bot token, so the URL slackFile returns is a route on your own server, never Slack’s url_private and never a URL with a token in its query string. The route:

  1. Checks that the visitor may see the file, the way the rest of your app checks access.
  2. Looks the file up with files.info (the files:read scope; the bot has to be able to see the file).
  3. Fetches its url_private with the bot token in an Authorization header, only when that URL is on https://files.slack.com, and without following redirects.
  4. Streams the body back if it’s an image, with your own cache headers.

The examples include this route for Next.js and Hono. A payload whose slack_file only has a url carries the file id in it (F… after the team id), so slackFile can pass that on instead.

Last updated on