img_caption_shortcode

SummerySummery

Builds the Caption shortcode output.

Syntax

img_caption_shortcode( array $attr, string $content = null )

DescriptionDescription

Allows a plugin to replace the content that would otherwise be returned. The filter is ‘img_caption_shortcode’ and passes an empty string, the attr parameter and the content parameter values.

The supported attributes for the shortcode are ‘id’, ‘caption_id’, ‘align’, ‘width’, ‘caption’, and ‘class’.

ParametersParameters

$attr

(array) (Required) Attributes of the caption shortcode.

  • 'id'
    (string) ID of the image and caption container element, i.e. <figure> or <div>.
  • 'caption_id'
    (string) ID of the caption element, i.e. <figcaption> or <p>.
  • 'align'
    (string) Class name that aligns the caption. Default 'alignnone'. Accepts 'alignleft', 'aligncenter', alignright', 'alignnone'.
  • 'width'
    (int) The width of the caption, in pixels.
  • 'caption'
    (string) The caption text.
  • 'class'
    (string) Additional class name(s) added to the caption container.

$content

(string) (Optional) Shortcode content.

Default value: null

ReturnReturn

(string) HTML content to display the caption.

SourceSource

File: wp-includes/media.php


			

ChangelogChangelog

Changelog
Version Description
5.1.0 The caption_id attribute was added.
3.9.0 The class attribute was added.
2.6.0 Introduced.
Scroll to Top