Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: A way to change video SRC priority and order? Want to list WebM...

Discussion in 'Misc WordPress Requests' started by Jacob Peattie, Oct 13, 2017.

  1. Jacob Peattie

    Guest

    Reply To: A way to change video SRC priority and order? Want to list WebM first, then MP4, by Jacob Peattie

    WordPress has a function, wp_video_extensions() that returns an array of supported video extensions. It seems any time WordPress needs to do anything based on these extensions it does so in the order that they are defined here. Thankfully this list of extensions is filterable, which means if you filter it to move webm to the front:


    function heiseheise_webm_first( $extensions ) {
    $new_extensions = $extensions;

    foreach ( $extensions as $key => $value ) {
    if ( $value === 'webm' ) {
    unset( $new_extensions[$key] );
    array_unshift( $new_extensions, $extensions[$key] );
    break;
    }
    }

    return $new_extensions;
    }
    add_filter( 'wp_video_extensions', 'heiseheise_webm_first' );


    I tested it adding a video with webm and mp4 sources, and webm came first when this filter was active, and mp4 came first when it wasn’t.

    Reply To: A way to change video SRC priority and order? Want to list WebM first, then MP4
     
    #1

Share This Page

Web Hosting