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:
- true
- false
Default / fallback value:
- false
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:
- all
- music
- video
- photo
- album
- document (requires Premium addon)
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.
- 20 (Logged in users)
- 40 (Friends)
- 60 (Private)
- 80 (Moderated media, requires rtMedia Moderation)
- 0 (Public)
Default / fallback value:
- 0 (Public media)
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:
- before: uploader on top of gallery
- after : uploader at the end of gallery
- true : uploader at the end of gallery (alias for after)
- false: don’t display uploader (does nothing)
Default / fallback value:
- false
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:
- 0 (numeric value zero)
- Numeric value greater than 0 (specifies how many thumbnails are loaded)
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:
- true
- false
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:
- true
- false
Default / fallback value:
- false
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.
- Create a Gallery with all uploaded media of any type (with Privacy = Public)
[rtmedia_gallery global="true"]
global
is “true” which means that the shortcode will ignore any specific context / context_id and display all media having privacy Public - Create a Gallery with all uploaded media of a specified type (with Privacy = Public)
[rtmedia_gallery global="true" media_type="photo"]
The media type to be displayed is specified by the media_type parameter. Additionally,global
is “true” which means that the shortcode will ignore any specific context / context_id and display all media of specified type having privacy Public - Create a Gallery that loads 10 media thumbnails at a time
[rtmedia_gallery global="true" media_type="photo" per_page="10"]
Theper_page
parameter will cause 10 items to 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. - Create a Gallery to display media of a particular album
[rtmedia_gallery global="false" context="profile" context_id="5" album_id="17"]
Thealbum_id
parameter specifies the unique ID of a album within a particular context. Additionally,global
is “false” which means that the shortcode will consider media only from the specified context / context_id. - Create a Gallery to list out only a particular’s media
[rtmedia_gallery context="profile" context_id="5"]
Thecontext = profile
specifies that the Gallery should fetch media from a user’s BuddyPress profile, while thecontext_id
specifies the exact user. - Create a Gallery to list out the logged in user’s media
[rtmedia_gallery context="profile"]
Since theglobal
parameter has not been explicitly specified in the above shortcode, the Gallery will assumeglobal
‘s defualt value, which is “false” and look for a specificcontext
andcontext_id
Since thecontext_id
has also not been specified, the Gallery will takecontext_id
‘s defualt fallback value, that is the current user’suser_id
Thus, this shortcode will dynamically display the media of the logged in user. - Create a Gallery to list out media that belongs to a specific BuddyPress group
[rtmedia_gallery context="group" context_id="1"]
Thecontext
parameter specifies that the media needs to be fetched from a BuddyPress group because it’s value is set to “group”. Thecontext_id
specifies which exact Group’s media needs to be fetched. - Create a Gallery to list out media uploaded to a particular album of a BuddyPress Group
[rtmedia_gallery context="group" context_id="1" album_id="48"]
Since each BuddyPress Group can albums created within it, you can specify a particular album and fetch media only from that album with thealbum_id
parameter. - Create a Gallery to list out media belonging to a specific page
[rtmedia_gallery context=page context_id=11]
Specify that you want the Gallery to fetch media only from a Pages with thecontext
parameter, and the specific page with thecontext_id
parameter. - Create a Gallery to list out all the Public media uploaded by a particular user
[rtmedia_gallery global=true media_author=1]
Using rtMedia, you users can upload media to different contexts across your website, like Buddypress Groups, Forums and their Profiles. This shortcode will list out all Public media that a user has uploaded across all contexts. This effectively creates a Gallery showcase for the user. - Create a Gallery to list out all media that a user has shared with his/her friends
[rtmedia_gallery context=profile privacy=40]
Since theglobal
parameter has not been explicitly specified in the above shortcode, the Gallery will assumeglobal
‘s defualt value, which is “false” and look for a specificcontext
andcontext_id
Since thecontext_id
has also not been specified, the Gallery will takecontext_id
‘s defualt fallback value, that is the current user’suser_id
The shortcode will also instruct the Gallery to only display media of Privacy level set to “Friends” through theprivacy
parameter,Thus, this shortcode will dynamically display any media that the current user has shared with his/her friends.