From d5c912a79bb970ae45641f137b1670a3faad955d Mon Sep 17 00:00:00 2001
From: Fabien Quatravaux <fabien.quatravaux@1nterval.com>
Date: Tue, 24 Jun 2014 10:56:45 +0200
Subject: [PATCH] [dev #28619] Add filters to tune mediaelement library
---
wp-includes/media.php | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/wp-includes/media.php b/wp-includes/media.php
index 974aa79..f9c0d18 100644
|
a
|
b
|
function wp_audio_shortcode( $attr, $content = '' ) {
|
| 1571 | 1571 | $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; |
| 1572 | 1572 | } |
| 1573 | 1573 | |
| 1574 | | $html = ''; |
| 1575 | | if ( 'mediaelement' === $library && 1 === $instances ) |
| 1576 | | $html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n"; |
| | 1574 | $html = apply_filters('wp_audio_shortcode_pre_html', '', $library, $instances); |
| 1577 | 1575 | $html .= sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) ); |
| 1578 | 1576 | |
| 1579 | 1577 | $fileurl = ''; |
| … |
… |
function wp_audio_shortcode( $attr, $content = '' ) {
|
| 1588 | 1586 | } |
| 1589 | 1587 | } |
| 1590 | 1588 | |
| 1591 | | if ( 'mediaelement' === $library ) |
| 1592 | | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1589 | $html .= apply_filters('wp_audio_shortcode_inside_html', '', $library, $fileurl, $post_id); |
| 1593 | 1590 | $html .= '</audio>'; |
| 1594 | 1591 | |
| 1595 | 1592 | /** |
| … |
… |
function wp_audio_shortcode( $attr, $content = '' ) {
|
| 1607 | 1604 | } |
| 1608 | 1605 | add_shortcode( 'audio', 'wp_audio_shortcode' ); |
| 1609 | 1606 | |
| | 1607 | function wp_mediaelement_audio_shortcode_pre_html($html, $library, $instances) { |
| | 1608 | if ( 'mediaelement' === $library && 1 === $instances ) |
| | 1609 | $html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n"; |
| | 1610 | return $html; |
| | 1611 | } |
| | 1612 | add_filter('wp_audio_shortcode_pre_html', 'wp_mediaelement_audio_shortcode_pre_html', 10, 3); |
| | 1613 | |
| | 1614 | function wp_mediaelement_audio_shortcode_inside_html($html, $library, $fileurl, $post_id) { |
| | 1615 | if ( 'mediaelement' === $library ) |
| | 1616 | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1617 | return $html; |
| | 1618 | } |
| | 1619 | add_filter('wp_audio_shortcode_inside_html', 'wp_mediaelement_audio_shortcode_inside_html', 10, 4); |
| | 1620 | |
| 1610 | 1621 | /** |
| 1611 | 1622 | * Return a filtered list of WP-supported video formats |
| 1612 | 1623 | * |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1788 | 1799 | $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; |
| 1789 | 1800 | } |
| 1790 | 1801 | |
| 1791 | | $html = ''; |
| 1792 | | if ( 'mediaelement' === $library && 1 === $instances ) |
| 1793 | | $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; |
| | 1802 | $html = apply_filters('wp_video_shortcode_pre_html', '', $library, $instances); |
| 1794 | 1803 | $html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) ); |
| 1795 | 1804 | |
| 1796 | 1805 | $fileurl = ''; |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1817 | 1826 | $html .= trim( $content ); |
| 1818 | 1827 | } |
| 1819 | 1828 | |
| 1820 | | if ( 'mediaelement' === $library ) |
| 1821 | | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1829 | $html .= apply_filters('wp_video_shortcode_inside_html', '', $library, $fileurl, $post_id); |
| 1822 | 1830 | $html .= '</video>'; |
| 1823 | 1831 | |
| 1824 | 1832 | $html = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $width, $html ); |
| … |
… |
function wp_video_shortcode( $attr, $content = '' ) {
|
| 1838 | 1846 | } |
| 1839 | 1847 | add_shortcode( 'video', 'wp_video_shortcode' ); |
| 1840 | 1848 | |
| | 1849 | function wp_mediaelement_video_shortcode_pre_html($html, $library, $instances) { |
| | 1850 | if ( 'mediaelement' === $library && 1 === $instances ) |
| | 1851 | $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; |
| | 1852 | return $html; |
| | 1853 | } |
| | 1854 | add_filter('wp_video_shortcode_pre_html', 'wp_mediaelement_video_shortcode_pre_html', 10, 3); |
| | 1855 | |
| | 1856 | function wp_mediaelement_video_shortcode_inside_html($html, $library, $fileurl, $post_id) { |
| | 1857 | if ( 'mediaelement' === $library ) |
| | 1858 | $html .= wp_mediaelement_fallback( $fileurl ); |
| | 1859 | return $html; |
| | 1860 | } |
| | 1861 | add_filter('wp_video_shortcode_inside_html', 'wp_mediaelement_video_shortcode_inside_html', 10, 4); |
| | 1862 | |
| 1841 | 1863 | /** |
| 1842 | 1864 | * Display previous image link that has the same post parent. |
| 1843 | 1865 | * |