Make WordPress Core


Ignore:
Timestamp:
03/20/2014 01:33:00 PM (11 years ago)
Author:
wonderboymusic
Message:

Unifying media controls and supporting playlists in the editor:

  • Support a caption attribute for audio and video shortcodes
  • In wp.media.audio|video, rename update to shortcode to allow these models to share the same mixins as wp.media.collection subclasses
  • When sending an audio or video shortcode to the editor, create a default caption if the user hasn't entered one. This currently only displays in the editor, not on the front end. Captions aren't tied to a specific attachment here because external sources are supported.
  • In the wp.mce.media mixin, in the edit method, read attr instead of data when attempting to parse the encoded shortcode. data does not automatically update when the attribute changes. This was a blessing to debug.
  • Add wp.mce.media.PlaylistView to support playlist views in TinyMCE
  • Expose WPPlaylistView to global scope and suppress auto-parsing of playlist nodes when in the admin. Allow WPPlaylistView to be passed metadata on creation instead of requiring a JSON blob to be parsed.
  • Remove all of the playlist logic from the wpgallery TinyMCE plugin.
  • In wp_prepare_attachment_for_js() return more data for audio/video so that playlists can have parity in the admin/front end.

See #27320.

File:
1 edited

Legend:

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

    r27625 r27640  
    10001000
    10011001/**
    1002  * Output and enqueue default scripts and styles for playlists.
     1002 * Output the templates used by playlists
    10031003 *
    10041004 * @since 3.9.0
    1005  *
    1006  * @param string $type Type of playlist: "audio" or "video."
    1007  */
    1008 function wp_playlist_scripts( $type ) {
    1009     wp_enqueue_style( 'wp-mediaelement' );
    1010     wp_enqueue_script( 'wp-playlist' );
     1005 */
     1006function wp_underscore_playlist_templates() {
    10111007?>
    1012 <!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ) ?>');</script><![endif]-->
    10131008<script type="text/html" id="tmpl-wp-playlist-current-item">
    10141009    <# if ( data.image ) { #>
     
    10461041<?php
    10471042}
     1043
     1044/**
     1045 * Output and enqueue default scripts and styles for playlists.
     1046 *
     1047 * @since 3.9.0
     1048 *
     1049 * @param string $type Type of playlist: "audio" or "video."
     1050 */
     1051function wp_playlist_scripts( $type ) {
     1052    wp_enqueue_style( 'wp-mediaelement' );
     1053    wp_enqueue_script( 'wp-playlist' );
     1054?>
     1055<!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ) ?>');</script><![endif]-->
     1056<?php
     1057    wp_underscore_playlist_templates();
     1058}
    10481059add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
    10491060
     
    13911402    $default_types = wp_get_audio_extensions();
    13921403    $defaults_atts = array(
     1404        'caption'  => '',
    13931405        'src'      => '',
    13941406        'loop'     => '',
     
    15501562    $default_types = wp_get_video_extensions();
    15511563    $defaults_atts = array(
     1564        'caption'  => '',
    15521565        'src'      => '',
    15531566        'poster'   => '',
     
    23332346        if ( isset( $meta['length_formatted'] ) )
    23342347            $response['fileLength'] = $meta['length_formatted'];
     2348
     2349        $response['meta'] = array();
     2350        $keys = array( 'title', 'artist', 'band', 'album', 'genre', 'year', 'length', 'length_formatted' );
     2351        foreach ( $keys as $key ) {
     2352            if ( ! empty( $meta[ $key ] ) ) {
     2353                $response['meta'][ $key ] = $meta[ $key ];
     2354            }
     2355        }
     2356
     2357        $id = get_post_thumbnail_id( $attachment->ID );
     2358        if ( ! empty( $id ) ) {
     2359            list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'full' );
     2360            $response['image'] = compact( 'src', 'width', 'height' );
     2361            list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'thumbnail' );
     2362            $response['thumb'] = compact( 'src', 'width', 'height' );
     2363        }
    23352364    }
    23362365
Note: See TracChangeset for help on using the changeset viewer.