From 848216b443936b1e3eb1c50825a9c639cabcda64 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 17 Mar 2008 20:08:43 +0000 Subject: [PATCH] do not insert empty links; use the file basename if no title given. Props andy. fixes #6249 git-svn-id: http://svn.automattic.com/wordpress/trunk@7348 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/media.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) 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() { - * + *