WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/31/2014 08:40:05 PM (6 years ago)
Author:
wonderboymusic
Message:

Support chromeless Vimeo via MEjs:

  • Bump MediaElement script loader versions to 2.16.2 - missed in [30634], oops!
  • Add Froogaloop to js/mediaelement scripts for Vimeo
  • Check for Vimeo in the same locations that YouTube is checked
  • Dynamically load Froogaloop script in admin when editing a TinyMCE view
  • Edit MediaElement to call mejs.$.extend instead of $.extend in mejs.HtmlMediaElementShim.createPlugin(), since $ is not available via WP's jQuery (I will report this upstream):

https://github.com/johndyer/mediaelement/blob/6f9a78e008de2de796a1797077a74a94763320f9/src/js/me-shim.js#L631

Fixes #29267.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r30982 r31016  
    17551755    }
    17561756
     1757    $is_vimeo = $is_youtube = false;
    17571758    $yt_pattern = '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#';
     1759    $vimeo_pattern = '#^https?://(.+\.)?vimeo\.com/.*#';
    17581760
    17591761    $primary = false;
    17601762    if ( ! empty( $atts['src'] ) ) {
    1761         if ( ! preg_match( $yt_pattern, $atts['src'] ) ) {
     1763        $is_vimeo = ( preg_match( $vimeo_pattern, $atts['src'] ) );
     1764        $is_youtube = (  preg_match( $yt_pattern, $atts['src'] ) );
     1765        if ( ! $is_youtube && ! $is_vimeo ) {
    17621766            $type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
    17631767            if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
     
    17651769            }
    17661770        }
     1771
     1772        if ( $is_vimeo ) {
     1773            wp_enqueue_script( 'froogaloop' );
     1774        }
     1775
    17671776        $primary = true;
    17681777        array_unshift( $default_types, 'src' );
     
    18491858                $fileurl = $atts[ $fallback ];
    18501859            }
    1851             if ( 'src' === $fallback && preg_match( $yt_pattern, $atts['src'] ) ) {
     1860            if ( 'src' === $fallback && $is_youtube ) {
    18521861                $type = array( 'type' => 'video/youtube' );
     1862            } elseif ( 'src' === $fallback && $is_vimeo ) {
     1863                $type = array( 'type' => 'video/vimeo' );
    18531864            } else {
    18541865                $type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
Note: See TracChangeset for help on using the changeset viewer.