From 4982de574717cb04f6806a27f2a89062d82b7a5c Mon Sep 17 00:00:00 2001 From: Ryan Boren 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: https://develop.svn.wordpress.org/trunk@7348 602fd350-edb4-49c9-b593-d223f7449a82 --- 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() { - * + *