---
title: "Plain images"
description: "Open the viewer from any img with data attributes."
canonical_url: "https://kukson777.github.io/nuxt-image-viewer/docs/guide/plain-images"
---
# Plain images

> Open the viewer from any img with data attributes.

`<ZoomImage>` is only a shortcut for a few attributes. Any `<img>` with `data-image-viewer` opens the viewer — HTML from a CMS, rendered Markdown, a third-party component.

```html
<img
  src="/photos/dawn-800.jpg"
  alt="Alpine dawn"
  tabindex="0"
  data-image-viewer
  data-image-viewer-src="/photos/dawn.jpg"
  data-image-viewer-width="2400"
  data-image-viewer-height="1600"
  data-image-viewer-caption="Alpine dawn"
>
```

## Attributes

<field-group>
<field name="data-image-viewer" type="boolean" :required="true">

Marks the image. Only `<img>` elements are picked up.

</field>

<field name="data-image-viewer-src" type="string">

The full image. Defaults to the image on the page (`currentSrc`).

</field>

<field name="data-image-viewer-width" type="number">

Natural width of the full image. Defaults to the natural width of the page image.

</field>

<field name="data-image-viewer-height" type="number">

Natural height of the full image. Defaults to the natural height of the page image.

</field>

<field name="data-image-viewer-caption" type="string">

Caption under the image in the viewer.

</field>

<field name="data-image-viewer-group" type="boolean">

On a container: the viewer scrolls through the marked images inside it only.

</field>
</field-group>

<note>

Add `tabindex="0"` so keyboard users can reach the image and open it with Enter or Space — `<ZoomImage>` does it for you.

</note>

## Markdown content

With Nuxt Content, mark the images of a page in one place — a prose image component:

```vue [components/content/ProseImg.vue]
<script setup lang="ts">
defineProps<{ src: string, alt?: string, width?: number, height?: number }>()
</script>

<template>
  <img
    :src
    :alt
    :width
    :height
    tabindex="0"
    data-image-viewer
  >
</template>
```

Then wrap the article in `data-image-viewer-group` so each page is its own gallery.

## Turning automatic opening off

The plugin listens to clicks and keys on the whole document. To open the viewer only from code, turn it off:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
  imageViewer: {
    autoOpen: false,
  },
})
```


## Sitemap

See the full [sitemap](https://kukson777.github.io/nuxt-image-viewer/sitemap.md) for all pages.
