A way to add a media to members-loop.php


#1

I would like to add a thumbnail of a picture on members listing page, ideally directly on members-loop page. It has to be a random image from the author’s album Any suggestion for doing that? Thanks


#2

Hello @ClaudeG,

There is not any direct option available to do so. However, we can guide you on which action you can use and what changes you can make in the query to fetch the result as per your need.

Please, take a look at this sample code and make changes as per your need - https://gist.github.com/BhargavBhandari90/805fd66a7ccf75fb3823bd1036b6a833

Thank you.


#3

Hello @pranalipatel Thanks for your help! I’v just tried to add this piece of code in members-loop.php just before “do_action( ‘bp_after_directory_members_list’ )” and put the css lines in my theme css and it didn’t change anything. Claude


#4

Hello @ClaudeG,

You need to add the PHP code into your theme’s functions.php file ( NOT in any members-loop.php file ) and the Custom CSS code under the below admin setting of rtMedia - rtMedia->settings->Custom CSS.

Please, once make sure you have added the code correctly and test again.

Thank you.


#5

OK!!! It works!!! For the css, it was ok. I’ll just have to refine the css to adapt it to my theme. Just in case you have an idea: how can I make the thunbnail appear at the bottom of a member list?

Thanks again! Very helpful


#6

Also, if I want to add a few thumbnails on the member’s profil page?


#7

Hello @ClaudeG,

Please, find my replies below to your questions:

how can I make the thunbnail appear at the bottom of a member list?

If you want the media at the bottom of a member list then you need to use a different action in the previously shared gist.

You can replace the currently used action bp_directory_members_actions with this one -> bp_directory_members_item.

Also, if I want to add a few thumbnails on the member’s profil page?

Well, you can just find available BuddyPress filters on the member’s profile page and reframe the same code to get the random picture we shared with you.

Here, I am attaching a screenshot which can show you the available hooks. You can pick it up according to your requirement.

Thanks.


#8

OK thanks @pranalipatel Perfect for members-loop, everything works. I didn’t find a way to had thumbnails on profile page, I’ve tried to add one the hooks in the “add action” part of the code without success. It is not that important since I may have to understand how “hooks” work if I want to make some progress in coding. Thanks


#9