BuddyDev

Embedding Photos, videos, audios, gallery from bp-gallery in the blog post

TOC:-

Introduction

Currently, BP Gallery enables you to use shortcodes to embed the media into your blog posts. It’s easy and versatile. There is only one shortcode and you can use a combination of parameters to embed what you want.

Shortcode:-

Sample short code

[bp-gallery param1="something"  param2="something" ....]

where “bp-gallery” is the shortcode and param1/param2 are various arguments as described below:-

Available arguments:-

  • owner_type:- optional. Its value could be [user/groups/events]. It will depend on whether you want to embed user galleries or group galleries or events gallery/media
  • show:-Optional. default value is “gallery”. It controls whether to embed some galleries or media . Possible values are :-gallery/media
  • owner_id:- optional. In case you know the owner id[i.e user id/group id], I am sure you won’t be using this argument, If you are specifying the owner_id, you must specify the “owner_type”
  • owner_slug:- optional. This is actually the user name /group slug whose gallery/media you want to embed, depending on the owner type, you can either specify a user name[e.g admin for admin's gallery] or group slug[e.g test-group for including test group's galleries]. Please note, if you are specifying owner_slug, you should always specify the owner_type
  • gallery_id:- optional, In case you are a database pro and feel very much inclined to use the knowledge, otherwise just do not use it. It there just for option.
  • gallery_slug:- optional,  If you want to embed all the media of a gallery in your post, you can specify the gallery slug[you can check it in the url], It’s easy, but It needs you to use the show=”media” and you must specify owner type and owner slug/id
  • orderby:- optional, possible values[ date/random/alphabet]
  • type: optional, you can use it to limit the type of embedded media. possible values [photo/video/audio]
  • max:- optional how many you want to show, by default is set to 5

Please note, gallery slug can be only used when you want to really embed media from a gallery. Also note, the requirement like some of the options must be specified in order to use others. Now let us see some examples:-

Examples:-

Embedding galleries:-

Embed 5 most recently updated sitewide galleries

[bp-gallery orderby="date"  max="5"]

Include 5 most recently updated user galleries

[bp-gallery owner_type="user"  max="5"  orderby="date" ]

Embedding 5  galleries of a user in the post

[bp-gallery owner_type="user" owner_slug="admin"  ]

It will embed the 5 galleries of admin[admin is the username ] into the post.

Now, let us only include 3 photo gallery

[bp-gallery owner_type="user" owner_slug="admin" type="photo" max="3"  ]

The above code filters the gallery type to photo and includes only 3 galleries.

Including Group galleries in the post:-

Include 5 most recently updated group galleries:-

[bp-gallery owner_type="groups" max="5" ]

Embed 5 galleries from  a group Test whose lug is “test-group” to post

[bp-gallery owner_type="groups" owner_slug="test-group"  ]

Now , let us include 4 photo gallery from test group

[bp-gallery owner_type="user" owner_slug="admin"  type="photo"  max="4"]

Similarly you can do for video/audio.

…..and so on. Please experiment and let me know in forums what we need to improve.

Embedding media:-

For including media, you must specify the show=”media” in the shortcode

Include most recently updated 10 photos from users

[bp-gallery show="media" owner_type="user" orderby="date"   type="photo" max="10"  ]

So, to include 10 most recent photos of admin, we will do something like this

[bp-gallery show="media" owner_type="user" owner_slug="admin"   type="photo" max="10"  ]

Include 10 most recent photos from groups

[bp-gallery show="media" owner_type="groups"    type="photo" max="10"  ]

Include 10 Most recent Photos from  test-group

[bp-gallery show="media" owner_type="groups" owner_slug="test-group"   type="photo" max="10"  ]

Include  5 images from  a gallery named test gallery[slug:test-gallery] belonging to Use xyz with username “xyz”

[bp-gallery show="media" owner_type="user" owner_slug="xyz"  gallery_slug="test-gallery"   max="10"  ]

….and so on. Please keep exploring while I am updating the docs :)