From 7757b7ff4e318d4fe99798b78b57360bd91df361 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 6 Oct 2006 00:34:58 +0000 Subject: [PATCH] Relativize links. Props mdawaffe. git-svn-id: http://svn.automattic.com/wordpress/trunk@4348 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/upload-functions.php | 10 +++++++--- wp-includes/formatting.php | 7 +++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/wp-admin/upload-functions.php b/wp-admin/upload-functions.php index 00bccf7ac..6268ea360 100644 --- a/wp-admin/upload-functions.php +++ b/wp-admin/upload-functions.php @@ -12,14 +12,18 @@ function wp_upload_display( $dims = false, $href = '' ) { $post_content = apply_filters( 'content_edit_pre', $post->post_content ); $class = 'text'; + $thumb_src = ''; $innerHTML = get_attachment_innerHTML( $id, false, $dims ); if ( $image_src = strstr($innerHTML, 'src="') ) { $image_src = explode('"', $image_src); $image_src = $image_src[1]; + $thumb_src = wp_make_link_relative($image_src); $class = 'image'; - $innerHTML = ' ' . $innerHTML; + $innerHTML = ' ' . str_replace($image_src, $thumb_src, $innerHTML); } + $src = wp_make_link_relative( get_the_guid() ); + $r = ''; if ( $href ) @@ -29,10 +33,10 @@ function wp_upload_display( $dims = false, $href = '' ) { if ( $href ) $r .= "\n"; $r .= "\n\t\t
\n\t\t\t

\n"; - $r .= "\t\t\t\t\n"; + $r .= "\t\t\t\t\n"; if ( $image_src ) - $r .= "\t\t\t\t\n"; + $r .= "\t\t\t\t\n"; if ( isset($width) ) { $r .= "\t\t\t\t\n"; $r .= "\t\t\t\t\n"; diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index d153fb964..11f006789 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -1070,4 +1070,11 @@ function js_escape($text) { return preg_replace("/\r?\n/", "\\n", addslashes($text)); } +function wp_make_link_relative( $link, $base = '' ) { + if ( !$base ) + $base = get_option( 'home' ); + if ( 0 === strpos($link, $base) ) + $link = substr_replace($link, '', 0, strlen($base)); + return $link; +} ?>