Gallery Shortcode

The Gallery shortcode allows you to create a dynamic Gallery of media. Each media displayed in the Gallery will meet a certain set of criteria, pre-defined by you.

To get an a general idea of how to use the Gallery shortcode, have a look at some common use cases at the end of this page.

The purpose of this shortcode is to provide a simpler way to display public galleries of media content on your site. To mainitain user privacy, the rtMedia Gallery shortcode will only fetch Public content by default.

This privacy rule can cause some side effects; for example, uploads in private BuddyPress Groups will not be displayed even if a user can access them by going to that particular BuddyPress Group.

We are aware of this, and have this included the privacy parameter to override the shortcode’s default behavior. Use it with caution!

Each of the following parameters are available with rtMedia Core. These parameters can be extended with some of our Premium Addons. This extended set can be found on this page.
Extended parameters are avaliable for the following addons:
• rtMedia Sorting
• rtMedia Custom Attributes
• rtMedia Favorites
• rtMedia WordPress Sitewide Gallery
• rtMedia Default Albums

Sorting Parameters

global

This flag mainly specifies whether the context and context_id values will be considered or not.

If set to “true”, both context values will be ignored; if set to “false”, context values are considered. In both cases, all other parameters will be unaffected.

Accepted values:

Default / fallback value:

 

context

Every media file has an associated context value associated with it. This value usually refers to the location where the media was uploaded.

Read more about context in this doc.

Note that this parameter only takes effect if the global parameter is set to “false”

Accepted values:

context Notes WordPress post page BuddyPress profile Set for uploads from the site-wide & personal Activity Feeds as well as “Media” tab group Set for uploads from BP Group Feed and “Media” tab bbPress topic Set when media is uploaded while creating a forum topic reply Set when media is uploaded with a reply to a forum topic rtMedia NULL Set for Global Albums created with rtMedia Default Albums dashboard Set for media uploaded to a rtMedia WordPress Sitewide Gallery comment Set for media attached to a WordPress comment via rtMedia WordPress Comment Attachments comment-media Set for media attached via the Comment Media feature

Note that the above values should be applied to media on a vanilla installation of WordPress + BuddyPress + rtMedia. Custom post types can apply different values.

Default / fallback value:

If the global parameter has been set to “false”, but context has not been specified, the parent’s post type will be sent as context.

context_id

Every media file has a context_id value associated with it. This is a unique numerical value.

Note that this parameter only takes effect if the global parameter is set to “false”

Please refer to this doc if you are not sure how to find the context ID of a post, page or media file.

Accepted values:

Any numerical value is accepted.

Default / fallback value:

If the global parameter has been set to “false”, but context_id has not been specified, the user’s user_id will be passed. If the user is not logged in, the parent’s context_id will be sent.

media_type

Accepted values:

Default / fallback value:

If not specified, all media types except “album” will be loaded

media_author

The media uploaded only by a specific can be displayed by passing that user’s user_id

Please refer to this doc if you are not sure how to find the user ID of a particular user.

Accepted values:

Any valid user_id

Default / fallback value:

None

album_id

The media uploaded to a specific album can be displayed by passing that albums’s ID along with it’s context and context_id

Please refer to this doc if you are not sure how to find the album ID of an album.

Note:
User-created albums have context = profile and context_id = user_id of current user.
Global albums (such as those created with created with rtMedia Default Albums) have context = NULL and context_id = NULL

Accepted values:

Any valid album ID

Default / fallback value:

None

media_ids

( This parameter is still under development. It requires you to add custom hooks to your functions.php file or your plugin file in order to work)

Allows you to pass specific media IDs of multiple media types at once.

This parameter cannot be used with the global, context or context_id parameters. If any of these are set, this parameter will be ignored. All other parameters work as usual.

Please refer to this doc if you are not sure how to find the media ID of any media file.

Accepted values:

A set of valid media IDs; combinations of multiple types (music, video, photo, album) are accepted

Default / fallback value:

None

privacy

This parameter specifies the privacy level that all the media in the Gallery should be at. To protect user privacy, the Gallery shortcode displays only Public media by default; this behavior can be overridden with this parameter.

Note that this parameter can only be used with global="false"

Accepted values:

Numerical values representing the different rtMedia default privacy levels are accepted.

Default / fallback value:

 

Presentation Parameters

The following parameters don’t affect what is displayed, just how it is displayed.

uploader

The best of both worlds- display an rtMedia Uploader along with the Gallery.

Accepted values:

Default / fallback value:

 

per_page

This value sets the number of media thumbnails that will be loaded per page (if Pagination is active) or when the “Load more” is clicked.

This will override the admin settings specified under List Media View in the rtMedia Settings.

Accepted values:

Default / fallback value:

None

lightbox

Use this parameter to override the “Use lightbox to display media” setting in the rtMedia Settings. This allows you to disable lightboxes in the Gallery, while keeping them active site-wide.

Accepted values:

Default / fallback value:

None

media_title

Use this parameter if you want to disable media titles in the Gallery. Hiding media titles creates a more compact look for the gallery.

Accepted values:

Default / fallback value:

 

Common use cases

The rtMedia Gallery shortcode (like any other WordPress shortcode) is written between a set of square brackets ([]) It looks something like:

[rtmedia_gallery global="false" context="post" context_id="23" media_type="photo" media_author="1"]

Below are a few ways in which the Gallery shortcode can be used. These are just some common use cases that we have come across; feel free to experiment or reach out to us if you don’t find what you are looking for.