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@keyargs}
  • value: Specifies the type of media information to retrieve (e.g., URL, title, caption).

  • keyargs: A set of key arguments that further refine the media query.

Key Arguments

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

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

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.

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. 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.

  4. Display Media Caption:

    {media:caption@id=321}

    Shows the caption of the media item with ID 321.

  5. Access Media Description:

    {media:description@id=654}

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

Did this answer your question?