diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 94dff14aaf..a983070fce 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -268,14 +268,15 @@ function media_upload_image() { if ( !empty($_POST['insertonlybutton']) ) { $src = $_POST['insertonly']['src']; - if ( !strpos($src, '://') ) + if ( !empty($src) && !strpos($src, '://') ) $src = "http://$src"; $alt = attribute_escape($_POST['insertonly']['alt']); if ( isset($_POST['insertonly']['align']) ) { $align = attribute_escape($_POST['insertonly']['align']); $class = " class='align$align'"; } - $html = "$alt"; + if ( !empty($src) ) + $html = "$alt"; return media_send_to_editor($html); } @@ -304,10 +305,13 @@ function media_upload_audio() { if ( !empty($_POST['insertonlybutton']) ) { $href = $_POST['insertonly']['href']; - if ( !strpos($href, '://') ) + if ( !empty($href) && !strpos($href, '://') ) $href = "http://$href"; $title = attribute_escape($_POST['insertonly']['title']); - $html = "$title"; + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; return media_send_to_editor($html); } @@ -336,10 +340,13 @@ function media_upload_video() { if ( !empty($_POST['insertonlybutton']) ) { $href = $_POST['insertonly']['href']; - if ( !strpos($href, '://') ) + if ( !empty($href) && !strpos($href, '://') ) $href = "http://$href"; $title = attribute_escape($_POST['insertonly']['title']); - $html = "$title"; + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; return media_send_to_editor($html); } @@ -368,10 +375,13 @@ function media_upload_file() { if ( !empty($_POST['insertonlybutton']) ) { $href = $_POST['insertonly']['href']; - if ( !strpos($href, '://') ) + if ( !empty($href) && !strpos($href, '://') ) $href = "http://$href"; $title = attribute_escape($_POST['insertonly']['title']); - $html = "$title"; + if ( empty($title) ) + $title = basename($href); + if ( !empty($title) && !empty($href) ) + $html = "$title"; return media_send_to_editor($html); } @@ -1067,7 +1077,7 @@ function type_form_image() { - * + *