Featured Media


rtmedia_featured($user_id)

The older tag (bp_media_featured()) will continue to work till the next few versions. Kindly change all instances, asap.

Used to display any media that the user has set as featured. It could be a video, audio or a photo.

For this to work, the appropriate switch will need to be turned on in rtMedia > Settings >Types. Read more: rtMedia settings’ types tab.

Arguments

$user_id

(Optional, not required on user profile)
The id of the user to fetch the featured media for. For example, if an admin decides to set a media item as featured for everyone in the community, his own user id can be passed to this function.

Example

In the default BuddyPress theme, find

/members/single/member-header.php

Replace the following code:

<?php if ( bp_is_active( 'activity' ) ) : ?>
	<div id="latest-update">
		<?php bp_activity_latest_update( bp_displayed_user_id() ); ?>
	</div>
<?php endif; ?>

with:

<div id="featured-media">
	<?php rtmedia_featured(); ?>
</div>

And instead of the latest update, the featured media would show up!

23 Comments

  1. Hi,
    I have made the changes as outlaid above and also enabled featured media via the BuddyPress Media settings.

    How exactly do I implement the featured media?

    • Author

      The user will have to set a particular media as featured. Such a button is present on the single media view/lightbox.

  2. Thanks Saurabh – I found it after I posted.

    I have a problem now though. When I deleted the last image that was used as a featured image, I received the following ‘lengthy’ error message:

    Fatal error: Uncaught exception ‘Exception’ with message ‘Sorry, the requested media does not exist.’ in /home//public_html/wp-content/plugins/buddypress-media/app/main/includes/BPMediaHostWordpress.php:59 Stack trace: #0 /home//public_html/wp-content/plugins/buddypress-media/app/main/includes/BPMediaHostWordpress.php(34): BPMediaHostWordpress->init(’5046′) #1 /home//public_html/wp-content/plugins/buddypress-media/app/main/profile/BPMediaFeatured.php(126): BPMediaHostWordpress->__construct(’5046′) #2 /home//public_html/wp-content/plugins/buddypress-media/app/main/profile/BPMediaFeatured.php(162): BPMediaFeatured->content() #3 /home//public_html/wp-content/plugins/buddypress-media/app/main/profile/BPMediaFeatured.php(157): bp_media_get_featured(false) #4 /home//public_html/wp-content/themes/parallelus-salutation/members/single/member-header.php(48): bp_media_featured() #5 /home//public_html/wp-includes/template.php(407): require_once(‘/home//…’) #6 /home/eve in /home/***/public_html/wp-content/plugins/buddypress-media/app/main/includes/BPMediaHostWordpress.php on line 59

    This message has locked me out of all BuddyPress pages on the site.

    If you have any ideas how to fix this, I would love to hear from you.

    Thank you for your help.

  3. hi

    does this work just like featured image on a normal post?

    I’m trying to get a featured image to show up on the profile page using our own theme and be great to use a members featured image, from their album, to display instead.

    have placed the code as per above but nothing shows. featured images are working normally for all the pages but the profile pages.
    thanks

    • Author

      This is for setting a featured media for each user. Each user has to set a featured media. This can then be displayed using the template tags.

  4. Is it possible to make this featured media clickable?
    And the thumb size, is there a way to adjust it?
    Thanks

  5. Author

    Yes, the size can be set on the BuddyPress Media Settings page. We have not made it clickable, by default. You can easily add a link around the image in the markup with a few lines of code.

  6. Hi Saurabh,
    One of the best buddypress plugins without a doubt. Thank you so much for your efforts. I have two questions which I hope you can help me with…

    To make it clickable, what would be the href and also how to make it open in the lightbox ?
    What would be the code to make the featured image ‘only’ show up if there is one set, other wise show the latest update. So IF bp_featured_media() is set, show it, ELSE show the latest update?

    Thanks for any assistance.

    • Author

      @serks,

      Thanks for the appreciation.

      We’ve just released an updated and rechristened version, rtMedia. Featured media was actually designed to act like a cover photo or video and is a sponsored feature. If you could add this to the forum as a feature request, we’ll deliberate on this.

      The second part is a little tricky. There’s a bug with the latest update that we’ve contributed a patch for. It should be released in 1.8. After that, we might be able to take care of this.

  7. Hey there,

    I’m trying to use the new < ?php rt_media_featured(); ?> tag in my member-header.php template to display a background image (rather than img src). I did this successfully with the previous version, but cannot seem to get it working in this one.

    I already have the CSS and everything set up for this — the only guidance I need is editing the line in RTMediaFeatured.php that outputs the image src. I simply need it to output a link to the featured image, as I provide the CSS to handle the rest.

    I’m very unfamiliar with php, so I apologize if it’s a simple edit (I managed to do it before, but I’m unsure of what I’m doing wrong this time).

    Thank you!

    • Ignore this, I found the solution. I had to reinstall this plugin since it was a bit broken from upgrading (luckily I’m developing the site now and it’s not live). I also used the correct tag, < ?php rtmedia_featured(); ?>, as it was labeled incorrectly in this documentation.

      For anyone that may need the same thing I needed, simply open RTMediaFeatured.php, find this line:

      <img src="' . $image_array[0] . '" alt="' . $featured->media_title . '" />;

      And change it to:

      $image_array[0] ;

      Keep in mind that you’ll need to do this every time you update the plugin. If anyone has a better solution than editing core files, please let me know.

  8. Ignore this, I found the solution. I had to reinstall this plugin since it was a bit broken from upgrading (luckily I’m developing the site now and it’s not live). I also used the correct tag, < ?php rtmedia_featured(); ?>, as it was labeled incorrectly in this documentation.

    For anyone that may need the same thing I needed, simply open RTMediaFeatured.php, find this line: '<img src="' . $image_array[0] . '" alt="' . $featured->media_title . '" />';

    And change it to this: $image_array[0];

    Keep in mind that you’ll need to do this anytime you update rtMedia. If anyone has a more elegant solution than editing core files, please let me know.

  9. The latest version of rtMedia seems to have the featured media always display the currently logged in users featured media rather than the profile that is being viewed.
    I fixed this issue by altering the function get() at line 62 of app/main/controllers/media/RTMediaFeatured.php.

    change…
    `$this->user_id = get_current_user_id();`
    to…
    `$this->user_id = bp_displayed_user_id();`

    Now for another issue I am having…

    I am using the following code to display a users featured media (image) like a cover photo on their profile. The code below checks if there is a featured media and displays it. If user has not set the featured media, than a default image loads.

    `< ?php if(bp_is_my_profile() AND rtmedia_get_featured() == NULL) : ?>

    < ?php endif; ?>`

    All this works great HOWEVER, when a single media is being viewed, the ‘Set Featured’ button is displayed 4 times.
    It seems that every instance of the tag creates a new ‘Set Featured’ button.
    Hope that makes sense.

    How can I stop this from happening?
    Thanks

  10. Staff

    @serksyener thanks for report this issue. it will fixed in next release(3.0.9)

    but i am not getting about why `Set Featured` button is displayed 4 Times. There are 4 action button for logged in user (Edit,Like,Set Feature, Delete) .

  11. @faishalsaiyed great to hear it will be fixed…this is one of the issues that has forced me to stick with the old buddypress media. Another issue is with the uploader and gallery shortcodes not working, but anyway….

    Yes, its displayed as many times as I use the tags.
    So in my function to display the featured image, I use rtmedia_get_featured() 3 times, so I end up seeing 4 ‘Set Featured’ buttons (including the original one). If featured media is set, all 4 buttons will say ‘Unset Featured’.

  12. Hi, I’m looking after a code snippet to call only the URL of the featured image set in BuddyPress profile. Is there such, and or how I could reach that?

    • Hey Ville,

      Check my post a few comments up — that will allow you to display only the featured image URL. If you need both, then I’m unsure since my current project may not be using rtMedia and I haven’t toyed around with it too much. Hopefully the devs can chime in for ya if that’s the case.

  13. Staff

    @villeterama-fi – Not exactly getting which featured image are you talking about here. Could you elaborate on your question on our support forums -> http://rtcamp.com/groups/rtmedia/forum/#new-topic-0

    • Hi!

      The solution you gave me worked like a charm till YESTERDAY, but now that I upgraded the plugin, the script returns FULL IMG-TAG instead of only the URL, messing the site :(

      <?php $user_id = bp_displayed_user_id(); rtmedia_featured($user_id); ?>
      

      What has to be changed to make it to return the URL only, so I can use it as a property for background source?

  14. Any help on this issue re: featured “image” not resizing. See Support Question: http://rtcamp.com/groups/rtmedia/forum/topic/rtmedia-featured-image-not-resizing/

    TIA


Comments are closed on this article.
Please use free our support forum for support and discussions.

People Who Like Thisx

Loading...