Support » Fixing WordPress » Changin YouTube Link and Iframe

  • aunpric

    (@aunpric)


    Hi In My site I have post with oembed Normal YouTube link and YouTube Iframe
    But for some reason I want to change it into something like This

    <div data-type="youtube" data-video-id="bTqVqk7FSmY"></div>

    Can Somebody Help Me How can I achieve It

    (bTqVqk7FSmY) This is youtube video id

Viewing 11 replies - 1 through 11 (of 11 total)
  • kjodle

    (@kjodle)

    Since oembed works perfectly fine in WordPress as is, I need to ask what is your ultimate goal here? If we knew what that was, we may be able to suggest a workaround for you.

    aunpric

    (@aunpric)

    I want to Use A Player Which doesn’t Support Iframe or oembed it need to be something like This <div data-type=”youtube” data-video-id=”bTqVqk7FSmY”></div> That why i want to change and My ultimate goal

    aunpric

    (@aunpric)

    @kjodle Here is The player website plyr.io

    kjodle

    (@kjodle)

    You would need a plugin to integrate that into WordPress. (Or a custom theme, but a plugin is easier.)

    I can see that you’ve already had a look at the current plugin that’s available for it. Maybe if you were more specific about what doesn’t work for you here, the plugin providers could help you. Either that, or you could fork it and create your own version.

    aunpric

    (@aunpric)

    @kjodle On Github The player has been Updated by the owner but WordPress Plugin Developer stop Providing update and The Problem is Player load to slowly And Use old css and Js If You can Help me with how can I load css and js From Cloudflare Cdn instead of my own server that would be helpful

    The Plugin Uses This Function to call css and Js

    wp_enqueue_style( $this->plyr, plugin_dir_url( __FILE__ ) . 'css/plyr-public.css', array(), $this->version, 'all' );
    
    wp_enqueue_script( $this->plyr, plugin_dir_url( __FILE__ ) . 'js/plyr.js', array( 'jquery' ), $this->version, false );
    
    		wp_enqueue_script( $this->plyr . '-public', plugin_dir_url( __FILE__ ) . 'js/plyr-public.js', array( $this->plyr, 'jquery' ), $this->version, false );
    
    	}
    

    Here is The Cdn File https://cdn.plyr.io/2.0.18/plyr.css
    https://cdn.plyr.io/2.0.18/plyr.js

    kjodle

    (@kjodle)

    If you don’t have a child theme, create one.

    Then throw this in your child theme’s functions.php file and see what happens

    
    function aunpric_plyr {
    
    wp_enqueue_style( cdn_plyr_css, src='https://cdn.plyr.io/2.0.18/plyr.css', array(), $this->version, 'all' );
    
    wp_enqueue_script( cdn_plyr_js, src='https://cdn.plyr.io/2.0.18/plyr.js', array( 'jquery' ), $this->version, false );
    
    }
    
    add_action( 'wp_enqueue_scripts', 'aunpric_plyr' );
    
    aunpric

    (@aunpric)

    Thanks man thats All i wanted

    aunpric

    (@aunpric)

    @kjodle Parse error: syntax error, unexpected ‘=’ in your code on line 27

    kjodle

    (@kjodle)

    Sorry, I left out a dollar sign. Try this:

    function aunpric_plyr {
    
    wp_enqueue_style( cdn_plyr_css, $src='https://cdn.plyr.io/2.0.18/plyr.css', array(), $this->version, 'all' );
    
    wp_enqueue_script( cdn_plyr_js, $src='https://cdn.plyr.io/2.0.18/plyr.js', array( 'jquery' ), $this->version, false );
    
    }
    
    add_action( 'wp_enqueue_scripts', 'aunpric_plyr' );
    aunpric

    (@aunpric)

    its working Thanks

    kjodle

    (@kjodle)

    Cheers! Glad I could help.

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.