BuddyDev

Search

remove embedding videos

  • Participant
    Level: Enlightened
    Posts: 36
    rav on #26789

    Hello,
    I’m trying to remove embedding videos from youtube but I can’t do it. I am trying to remove youtube using the instructions
    https://codex.wordpress.org/Function_Reference/wp_oembed_remove_provider

    but youtube videos are still being embedded. How to do it.

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #26792

    Hi Rav,
    Please share the complete code. It could be related to either what values you are passing or the hook you are using.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 36
    rav on #26802

    Hi @Brajesh Singh

    I tried the possibilities that I found on the web:

    wp_oembed_remove_provider ( ‘#http: // (www \.)? YouTube \ .com / watch. * and #’);
    wp_oembed_remove_provider ( ‘#https: // (www \.)? YouTube \ .com / watch. * and #’);
    wp_oembed_remove_provider ( ‘#http: // youtu \ .be /.*# I’);
    wp_oembed_remove_provider ( ‘#https: // youtu \ .be /.*# I’);

    Unfortunately it doesn’t work. Now, however, another question came to my mind.
    Can you change the embedding to display only image instead of video?
    Even for links from YouTube?

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #26817

    Hi,
    Please give a try to this

    
    add_action( 'plugins_loaded', function () {
    	// remove youtube support.
    	wp_oembed_remove_provider( '#https?://((m|www)\.)?youtube\.com/watch.*#i' );
    	wp_oembed_remove_provider( '#https?://youtu\.be/.*#i' );
    } );
    
    

    It should most probably work.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved