Make WordPress Core


Ignore:
Timestamp:
03/17/2008 08:08:43 PM (18 years ago)
Author:
ryan
Message:

do not insert empty links; use the file basename if no title given. Props andy. fixes #6249

File:
1 edited

Legend:

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

    r7304 r7348  
    269269    if ( !empty($_POST['insertonlybutton']) ) {
    270270        $src = $_POST['insertonly']['src'];
    271         if ( !strpos($src, '://') )
     271        if ( !empty($src) && !strpos($src, '://') )
    272272            $src = "http://$src";
    273273        $alt = attribute_escape($_POST['insertonly']['alt']);
     
    276276            $class = " class='align$align'";
    277277        }
    278         $html = "<img src='$src' alt='$alt'$class />";
     278        if ( !empty($src) )
     279            $html = "<img src='$src' alt='$alt'$class />";
    279280        return media_send_to_editor($html);
    280281    }
     
    305306    if ( !empty($_POST['insertonlybutton']) ) {
    306307        $href = $_POST['insertonly']['href'];
    307         if ( !strpos($href, '://') )
     308        if ( !empty($href) && !strpos($href, '://') )
    308309            $href = "http://$href";
    309310        $title = attribute_escape($_POST['insertonly']['title']);
    310         $html = "<a href='$href' >$title</a>";
     311        if ( empty($title) )
     312            $title = basename($href);
     313        if ( !empty($title) && !empty($href) )
     314            $html = "<a href='$href' >$title</a>";
    311315        return media_send_to_editor($html);
    312316    }
     
    337341    if ( !empty($_POST['insertonlybutton']) ) {
    338342        $href = $_POST['insertonly']['href'];
    339         if ( !strpos($href, '://') )
     343        if ( !empty($href) && !strpos($href, '://') )
    340344            $href = "http://$href";
    341345        $title = attribute_escape($_POST['insertonly']['title']);
    342         $html = "<a href='$href' >$title</a>";
     346        if ( empty($title) )
     347            $title = basename($href);
     348        if ( !empty($title) && !empty($href) )
     349            $html = "<a href='$href' >$title</a>";
    343350        return media_send_to_editor($html);
    344351    }
     
    369376    if ( !empty($_POST['insertonlybutton']) ) {
    370377        $href = $_POST['insertonly']['href'];
    371         if ( !strpos($href, '://') )
     378        if ( !empty($href) && !strpos($href, '://') )
    372379            $href = "http://$href";
    373380        $title = attribute_escape($_POST['insertonly']['title']);
    374         $html = "<a href='$href' >$title</a>";
     381        if ( empty($title) )
     382            $title = basename($href);
     383        if ( !empty($title) && !empty($href) )
     384            $html = "<a href='$href' >$title</a>";
    375385        return media_send_to_editor($html);
    376386    }
     
    10681078            <th valign="top" scope="row" class="label">
    10691079                <span class="alignleft"><label for="insertonly[alt]">' . __('Description') . '</label></span>
    1070                 <span class="alignright"><abbr title="required">*</abbr></span>
     1080                <span class="alignright"><abbr title="required" class="required">*</abbr></span>
    10711081            </th>
    10721082            <td class="field"><input id="insertonly[alt]" name="insertonly[alt]" value="" type="text"></td>
Note: See TracChangeset for help on using the changeset viewer.