How to pull Featured Media through WP's featured image -tag?


#1

I already asked this on other thread, but possibly because I'm such a neebie, I need some extra guidance :)

The site in question is www.fimage.fi, where I've created conditional tag for frontpage to show a slider, and all subpages to go with featured image set for them.

I have a template, which uses WP's featured image as a header image on pages. I use code as below to do that:

<?php global $post; ?>  
<?php  
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array(1000,400), false, '' );  
?>  
  

Now, on BuddyPress members profile pages are obviously returning empty for featured image, because they are dynamic, and no option to set that in. Is there a way, to get Featured Media to be pulled through that code snippet? Or condition or something?

Because for some reason, I've set one picture as a featured media on my profile, but it returns nothing. Am I missing a function or something.

Thank you on forehand.


#2

@villeterama-fi - You must be searching for this -> http://rtcamp.com/rtmedia/docs/admin/featured-media/


#3

Thanks Joshua,

I've tried to follow that and all, but that script is not returning a thing to me. And setting an image as featured, it does'nt pop-up in profile either, or should it appear somewhere by default?


#4

As per the link I provided, the featured media would show up only at places where you have inserted rtmedia_featured($user_id) in your theme files. So basically it would depend on where you place the code.


#5

You can find the code for its ouput here -> https://github.com/rtCamp/rtMedia/blob/master/app/main/controllers/media/RTMediaFeatured.php#L112-L143


#6

Ok, and thank you a lot. I'll try.

Is it rt_media_featured (as mentioned here: http://rtcamp.com/rtmedia/docs/admin/featured-media/) or rtmedia_featured as you wrote here..?


#7

It is as I have mentioned. Will be correcting the typo on that page too.


#8

THIS WAS A PRIVATE REPLY WITH POST_ID 45573

Attachment Link(s):

http://rtcamp.com/wp-content/uploads/rtMedia/topics/45461/2013/09/Screen-Shot-2013-09-04-at-15.01.10.png

http://rtcamp.com/wp-content/uploads/rtMedia/topics/45461/2013/09/Screen-Shot-2013-09-04-at-15.02.03.png

http://rtcamp.com/wp-content/uploads/rtMedia/topics/45461/2013/09/Screen-Shot-2013-09-04-at-15.04.10.png


#9

$user_id should be substituted with the user id of the user whose featured image you want to display.

Something like this

$user_id = get_current_user_id(); // for the logged in user id  

or

$user_id = bp_displayed_user_id(); // for the displayed users id  

#10

Also you need to have set one of your media as featured.


#11

WORKS! didn't know about that deifinion for user to be added. Thanks a punch!


#12

Glad to know you could get it working :)


#13