Plugin Page

DICOM — WP Medical Image Viewer

View Plugin

Shortcode

The [dicom_viewer] shortcode is an alternative to the Gutenberg block for embedding DICOM viewers. It’s useful if you’re using the classic editor or writing custom templates.


Basic Usage

The simplest way to add a viewer is to provide a file ID from your media library:

[dicom_viewer id="123"]

Replace 123 with your file’s WordPress attachment ID (find this in Media > Library).

Or provide a direct file URL:

[dicom_viewer url="https://example.com/path/to/file.dcm"]

Using the Classic Editor

If you’re using the classic editor instead of Gutenberg, the DICOM Viewer adds a toolbar button. Click the DICOM Viewer icon in the editor toolbar to insert the shortcode with a file selector dialog.


Shortcode Attributes

All attributes are optional except one of id or url. Full details are in the Shortcode Reference.

Common attributes:

[dicom_viewer
  id="123"
  height="600px"
  show_info="false"
  layout="auto"
  grid_min_series="3"
  anon_level="standard"
]

Setting Viewport Defaults

You can pre-set the viewer’s starting zoom and position:

[dicom_viewer
  id="123"
  default_zoom="2.0"
  default_series="1"
  default_slide="15"
]

For multi-series with grid layout, you can set per-pane values:

[dicom_viewer
  id="123"
  layout="grid"
  default_slides="0,5,10"
  default_zooms="1.5,1.5,1.5"
  default_wcs="40,40,40"
  default_wws="400,400,400"
]

Shortcode Reference

This page lists all options you can use in the [dicom_viewer] shortcode to customize how the viewer displays.


Choosing Your File

You must provide either a file ID from your media library OR a direct URL:

AttributeTypeDefaultDescription
idinteger0WordPress media library attachment ID
urlstring""Direct URL to a .dcm or .zip file

Note: Use id when the file is in your WordPress media library (preferred). Use url for files hosted externally.


Sizing

OptionValuesWhat it does
heighte.g., 480px, 600px, 70vhHow tall the viewer should be
widthe.g., 100%, 800pxHow wide the viewer should be

Buttons & Controls

OptionValuesWhat it does
show_downloadtrue or falseShow/hide the download button
show_infotrue or falseShow/hide the info button (displays image metadata)
show_pan_controltrue or falseShow/hide the Pan tool
show_zoom_controltrue or falseShow/hide the Zoom tool and zoom buttons
show_wl_controltrue or falseShow/hide the window/level controls
show_nav_buttonstrue or falseShow/hide the next / previous slice buttons
show_slidertrue or falseShow/hide the slice slider

Multiple Series

OptionValuesWhat it does
layoutauto, single, gridSingle image or side-by-side grid
grid_cols1, 2, 3, 4How many columns in grid view
grid_min_series2 to 10Minimum number of series required before layout="auto" switches to grid
ref_linestrue, falseShow/hide reference lines connecting panes
show_series_selectortrue or falseShow/hide the series selector UI
show_pane_selectortrue or falseShow/hide the pane count selector in grid mode
series_displaylegacy compatibilityOlder content may still use none to hide the selector

Hiding Sensitive Information

OptionValuesWhat it does
anon_leveloff, basic, standard, strictHide patient info in the metadata display
  • off = show all information
  • basic = hide patient name and ID
  • standard = hide patient info + hospital details
  • strict = hide almost everything except the image

Default Viewport (Advanced)

If you want the viewer to open at a specific series, slice, zoom level, or window/level, you can set:

OptionWhat it does
default_seriesStarting series index (0 = first series, 1 = second, etc.)
default_slideStarting slice index within the series
default_zoomStarting zoom level (1.0 = normal, 2.0 = 2x zoom, 0.5 = zoomed out)
default_pan_xStarting horizontal pan offset
default_pan_yStarting vertical pan offset
default_wcStarting window center
default_wwStarting window width

Example:

[dicom_viewer id="42" default_series="1" default_slide="12" default_zoom="1.5"]

For grid layout with multiple panes, you can set different values for each pane:

[dicom_viewer
  id="42"
  layout="grid"
  default_panes="3"
  default_slides="0,5,10"
  default_zooms="1.5,1.5,2.0"
  default_wcs="40,40,60"
  default_wws="400,400,250"
  default_pane_series="0,0,1"
]

Additional grid viewport options:

OptionWhat it does
default_panesNumber of panes to show initially
default_slidesComma-separated slice indices per pane
default_zoomsComma-separated zoom levels per pane
default_pan_xsComma-separated horizontal pan offsets per pane
default_pan_ysComma-separated vertical pan offsets per pane
default_wcsComma-separated window center values per pane
default_wwsComma-separated window width values per pane
default_pane_seriesComma-separated series indices per pane

Using Global Settings

If you don’t specify an option in the shortcode, it uses the default from DICOM Viewer.

For example, if your global default height is 480px, you don’t need to add height="480px" to every shortcode.


True/False Values

For options that take true or false, you can write:

  • true, 1, or yes for on
  • false, 0, or no for off

Example: show_info="true" or show_download="1"


Common Examples

Just show the image:

[dicom_viewer id="123"]

Make it taller:

[dicom_viewer id="123" height="800px"]

Hide patient info:

[dicom_viewer id="123" anon_level="strict"]

Show multiple images side-by-side:

[dicom_viewer id="123" layout="grid" grid_cols="2"]

Start zoomed in:

[dicom_viewer id="123" default_zoom="2.0"]

Don’t allow downloads:

[dicom_viewer id="123" show_download="false"]