Make WordPress Core


Ignore:
Timestamp:
10/24/2009 11:43:42 AM (16 years ago)
Author:
azaozz
Message:

When inserting the embed shortcode in TinyMCE replace it with a placeholder image, update the 'wordpress', 'wpeditimage' and 'wpgallery' TinyMCE plugins, fix the audio and video "From URL" tabs in the uploader popup to accept only URLs for embedding, see #10337

File:
1 edited

Legend:

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

    r12081 r12098  
    167167/* ]]> */
    168168</script>
    169     <?php
     169<?php
    170170    exit;
    171171}
     
    482482
    483483    if ( !empty($_POST['insertonlybutton']) ) {
    484         $src = $_POST['insertonly']['src'];
    485         if ( !empty($src) && !strpos($src, '://') )
    486             $src = "http://$src";
    487         $alt = esc_attr($_POST['insertonly']['alt']);
    488         if ( isset($_POST['insertonly']['align']) ) {
    489             $align = esc_attr($_POST['insertonly']['align']);
    490             $class = " class='align$align'";
     484        $alt = $align = '';
     485        if ( !empty($_POST['insertonly']['embed-src']) ) {
     486            $src = $_POST['insertonly']['embed-src'];
     487            if ( !strpos($src, '://') )
     488                $src = "http://$src";
     489            $html = '[embed]' . $src . '[/embed]';
     490        } else {
     491            $src = $_POST['insertonly']['src'];
     492            if ( !empty($src) && !strpos($src, '://') )
     493                $src = "http://$src";
     494            $alt = esc_attr($_POST['insertonly']['alt']);
     495            if ( isset($_POST['insertonly']['align']) ) {
     496                $align = esc_attr($_POST['insertonly']['align']);
     497                $class = " class='align$align'";
     498            }
     499            if ( !empty($src) )
     500                $html = "<img src='$src' alt='$alt'$class />";
    491501        }
    492         if ( !empty($src) )
    493             $html = "<img src='$src' alt='$alt'$class />";
     502
    494503        $html = apply_filters('image_send_to_editor_url', $html, $src, $alt, $align);
    495504        return media_send_to_editor($html);
     
    587596        if ( !empty($href) && !strpos($href, '://') )
    588597            $href = "http://$href";
    589         $title = esc_attr($_POST['insertonly']['title']);
    590         if ( empty($title) )
    591             $title = basename($href);
    592         if ( !empty($title) && !empty($href) )
    593             $html = "<a href='$href' >$title</a>";
    594         $html = apply_filters('audio_send_to_editor_url', $html, $href, $title);
     598
     599        $html = '[embed]' . $href . '[/embed]';
     600        $html = apply_filters('audio_send_to_editor_url', $html, $href);
    595601        return media_send_to_editor($html);
    596602    }
     
    641647        if ( !empty($href) && !strpos($href, '://') )
    642648            $href = "http://$href";
    643         $title = esc_attr($_POST['insertonly']['title']);
    644         if ( empty($title) )
    645             $title = basename($href);
    646         if ( !empty($title) && !empty($href) )
    647             $html = "<a href='$href' >$title</a>";
    648         $html = apply_filters('video_send_to_editor_url', $html, $href, $title);
     649
     650        $html = '[embed]' . $href . '[/embed]';
     651        $html = apply_filters('video_send_to_editor_url', $html, $href);
    649652        return media_send_to_editor($html);
    650653    }
     
    695698        if ( !empty($href) && !strpos($href, '://') )
    696699            $href = "http://$href";
     700
    697701        $title = esc_attr($_POST['insertonly']['title']);
    698702        if ( empty($title) )
     
    15141518        var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = '';
    15151519
    1516         if ( '' == f.src.value || '' == t.width ) return false;
     1520        if ( '' != document.getElementById('embed-src').value )
     1521            return true;
     1522
     1523        if ( '' == f.src.value || '' == t.width )
     1524            return false;
    15171525
    15181526        if ( f.title.value ) {
     
    15411549        var win = window.dialogArguments || opener || parent || top;
    15421550        win.send_to_editor(html);
     1551        return false;
    15431552    },
    15441553
     
    15491558        document.getElementById('go_button').style.color = '#bbb';
    15501559        if ( ! document.forms[0].src.value )
    1551             document.getElementById('status_img').src = 'images/required.gif';
    1552         else document.getElementById('status_img').src = 'images/no.png';
     1560            document.getElementById('status_img').innerHTML = '*';
     1561        else document.getElementById('status_img').innerHTML = '<img src="images/no.png" alt="" />';
    15531562    },
    15541563
     
    15591568        t.height = t.preloadImg.height;
    15601569        document.getElementById('go_button').style.color = '#333';
    1561         document.getElementById('status_img').src = 'images/yes.png';
     1570        document.getElementById('status_img').innerHTML = '<img src="images/yes.png" alt="" />';
    15621571    },
    15631572
     
    15691578            return false;
    15701579        }
    1571         document.getElementById('status_img').src = 'images/wpspin_light.gif';
     1580        document.getElementById('status_img').innerHTML = '<img src="images/wpspin_light.gif" alt="" />';
    15721581        t.preloadImg = new Image();
    15731582        t.preloadImg.onload = t.updateImageData;
     
    19211930
    19221931    return '
     1932    <h4 class="media-sub-title">' . __('Embed a picture from a web site that supports oEmbed') . '</h4>
    19231933    <table class="describe"><tbody>
    19241934        <tr>
    1925             <th valign="top" scope="row" class="label" style="width:120px;">
     1935            <th valign="top" scope="row" class="label" style="width:130px;">
     1936                <span class="alignleft"><label for="embed-src">' . __('Embed image') . '</label></span>
     1937                <span class="alignright"><abbr title="required" class="required">*</abbr></span>
     1938            </th>
     1939            <td class="field"><input id="embed-src" name="insertonly[embed-src]" value="" type="text" /></td>
     1940        </tr>
     1941
     1942        <tr>
     1943            <td></td>
     1944            <td>
     1945                <input type="submit" class="button" name="insertonlybutton" value="' . esc_attr__('Embed') . '" />
     1946            </td>
     1947        </tr>
     1948    </tbody></table>
     1949
     1950    <h4 class="media-sub-title">' . __('Insert an image from another web site') . '</h4>
     1951    <table class="describe"><tbody>
     1952        <tr>
     1953            <th valign="top" scope="row" class="label" style="width:130px;">
    19261954                <span class="alignleft"><label for="src">' . __('Image URL') . '</label></span>
    1927                 <span class="alignright"><img id="status_img" src="images/required.gif" title="required" alt="required" /></span>
     1955                <span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span>
    19281956            </th>
    19291957            <td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td>
     
    19992027            <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
    20002028        </tr>
    2001         <tr>
    2002             <th valign="top" scope="row" class="label">
    2003                 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
    2004                 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
    2005             </th>
    2006             <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
    2007         </tr>
    2008         <tr><td></td><td class="help">' . __('Link text, e.g. &#8220;Still Alive by Jonathan Coulton&#8221;') . '</td></tr>
     2029
    20092030        <tr>
    20102031            <td></td>
     
    20342055            <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>
    20352056        </tr>
    2036         <tr>
    2037             <th valign="top" scope="row" class="label">
    2038                 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
    2039                 <span class="alignright"><abbr title="required" class="required">*</abbr></span>
    2040             </th>
    2041             <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>
    2042         </tr>
    2043         <tr><td></td><td class="help">' . __('Link text, e.g. &#8220;Lucy on YouTube&#8221;') . '</td></tr>
     2057
    20442058        <tr>
    20452059            <td></td>
Note: See TracChangeset for help on using the changeset viewer.