Skip to main content
Media - Dynamic Shortcodes

Discover the media Dynamic Shortcode. Understand its syntax, key arguments, and practical examples.

Updated over a week ago

The Media Dynamic Shortcode is a shortcode used for embedding and manipulating media content within web pages. It allows for precise control over media elements, by accepting specific arguments and options.

Syntax

The basic syntax for the media Dynamic Shortcode is:

{media:value}
  • value Specifies the type of media information to retrieve (e.g., URL, title, caption).

Key Arguments

  • id The unique identifier for the media item (required).

    {media:value @ID=3}

  • size Defines the size of the media item (e.g., thumbnail, medium, large). Default is 'large'.

    {media:url @size=thumbnail}

Value

The value argument specifies what information you want to retrieve. The supported options are:

  • url - The URL to the media file.

  • title - The title of the media file.

  • caption - The caption of the media file.

  • description - The description of the media file.

  • alt-text - The Alternative Text of the media file.

  • width - only for images.

  • height - only for images.

  • html - to display Images

  • file-path - Retrieves the file path

For example:

{media:url @ID=123}

Would output the URL to the media file with ID 123.

Examples

  1. Retrieve Image URL

    {media:url@id=123}

    This example fetches the URL of the media item with ID 123.

  2. Get Media Title

    {media:title@id=456}

    Retrieves the title of the media item with ID 456.

  3. Print the Featured Image of the Current Post

    {media:image @id={post:featured-image-id}}

    {post:featured-image-id} returns the Media ID of the Featured Image

    It is recommended to check if the Featured Image exists before printing it on the screen, using the conditions:

    {if:{post:featured-image-id}
    {media:image @id={post:featured-image-id}}
    }

  4. Fetch Image with Specific Size

    {media:url@id=789 size=thumbnail}

    Obtains the URL of the media item with ID 789, specifically in thumbnail size. If you do not specify a size, it will default to the full size image URL.

  5. Display Media Caption

    {media:caption@id=321}

    Shows the caption of the media item with ID 321.

  6. Access Media Description

    {media:description@id=654}

    Retrieves the description text of the media item with ID 654.

Did this answer your question?