# Shortcode

The `[sleek-pixel-image]` shortcode outputs a Pixel image as an `<img>` tag
wherever WordPress runs shortcodes, such as post content. It is the shortcode
form of [`sleekPixel_get_image()`](/docs/pixel/rendering/function.md) and takes
the same values.

## Usage

```text
[sleek-pixel-image id="123" key="post-card"]
```

## Attributes

- `id` (required): the [image's ID](/docs/pixel/images.md#the-image-id).
- `key` (required): a name for this use of the image. Pixel keeps one rendered
  file per image, post and key, so give each use its own key. The value is a
  single key; commas do not split it.
- `postid` (optional): the post whose data fills the image. Defaults to the
  current post.
- `data` (optional): JSON merged into the image's
  [dynamic data](/docs/pixel/dynamic-data.md), such as
  `data='{"post":{"title":"Custom title"}}'`. Invalid JSON is ignored. It
  applies only in content whose author can publish unfiltered HTML
  (administrators and editors on a single site, super admins on a network);
  for any other author the image renders with its normal dynamic data. In PHP,
  [`sleekPixel_get_image()`](/docs/pixel/rendering/function.md) takes the same
  value without that limit.

Without `id` or `key` the shortcode outputs nothing.

## Output

The shortcode returns an `<img>` tag with the canvas's width and height and an
empty `alt`. It returns nothing while the image has no rendered file yet, which
happens on the first request with
[asynchronous processing](/docs/pixel/settings/options.md#image-processing) or
from a visitor who is not signed in, and when the server has no Imagick
extension. While a changed design renders again, it returns the previous file.

## In templates

In PHP, call [`sleekPixel_get_image()`](/docs/pixel/rendering/function.md)
directly rather than through `do_shortcode()`.
