BuddyBoss Home – Web Support Forums General BuddyPress (general issues) Embed Youtube Video on Profile by pasting link

Viewing 9 posts - 1 through 9 (of 9 total)
  • Question

    #37526
    @andy8mcdonalds

    I’ve been looking for the best way to activate oEmbed on Buddypress profile pages so that I can have my users paste a youtube link into a text field and it will automatically embed the video when viewed. Does anyone know how to get this to work? Do I need to add anything to my bp-custom.php page or upload any plugin?

    Answers

    #37681

    Anonymous
    @

    Hi @andy8mcdonalds it need to echo the fields values using embedded player, and it need to alter the member-header.php or home.php inside the /boss-child/buddypress/members/single/ on the basis of your final location where you want to display that video on the user profile

    if you had created a field for youtube video url with name : youtube

    <?php
    $youtube =  xprofile_get_field_data('field=youtube', bp_displayed_user_id()) ;
    if (strlen($youtube) > 0 ) 
       echo '<div class="video-container"><iframe src="' . $youtube. '" frameborder="0" allowfullscreen></iframe></div>';
    }
    ?>

    Height and Width you can control easily via adding some responsive css for video-container

    Regards
    Varun Dubey

    #37771
    @andy8mcdonalds

    Thank you @vapvarun this is perfect! I appreciate your help in this

    #37773
    @andy8mcdonalds

    @vapvarun so would this need to be inserted just on member-header.php or home.php? I placed this inside profile-loop.php and can’t seem to get this to work yet.

    #37996
    @style960

    @andy8mcdonalds @vapvarun My understanding was that oEmbed worked straight out of the box for Buddypress. It certainly does for me on an install with Boss theme. What I can’t figure out is how to customize the huge activity post this creates since the CSS used is pulled from the external source – Youtube, Vimeo etc. and I can’t figure out a way to override it?

    #38000
    @style960

    @andy8mcdonalds @vapvarun Also, does anyone know how to pull content into the activity stream by copying and pasting a link in? Featured image, and an excerpt of the text? This seems another area where Buddypress is way behind modern practices.

    #38015
    @andy8mcdonalds

    @style960 where in buddypress does this work for you? I have the boss theme as well, and when I post this on the activity stream it works, but what I’m trying to do is post in on a profile as a custom profile field.

    #38018
    @style960

    @andy8mcdonalds Ah my mistake, my install only works in the same manner as your own. I have raised two tickets with Buddypress support around the size these embeds are added at, and how to show content instead of just a hyperlink.

    #45327
    @kahunaburger

    @andy8mcdonalds @style960 Not sure if you are still looking for a solution, but you can try this:

    function bp_embed_in_profile() {
    	add_filter( 'bp_get_the_profile_field_value', 'bp_enable_embed_in_profile', 9, 3 );
    }
    add_action( 'bp_init', 'bp_embed_in_profile', 0 );
    
    function bp_enable_embed_in_profile( $val, $type, $key ) {
    
    	$field = new BP_XProfile_Field( $key );
    	$field_name = $field->name;
    	
    	$provider = array( 'youtube', 'vimeo', 'instagram', 'bliptv', 'twitter');
    	
    	if(  strtolower( $field_name ) == in_array( strtolower( $field_name ) , $provider ) ) {
                    $val = strip_tags( $val );
    		return wp_oembed_get( $val, array( 'width' => 400 ) );	
    	}
    		return $val;
    }

    Create a multi-line profile field in the admin and give it the name of the oEmbed provider. `

    You can change youtube, vimeo, etc. in this line to whatever profile field names you want it to work in if you don’t want to use provider names:`

    $provider = array( 'youtube', 'vimeo', 'instagram', 'bliptv', 'twitter');

Viewing 9 posts - 1 through 9 (of 9 total)
  • The question ‘Embed Youtube Video on Profile by pasting link’ is closed to new replies.