Relativize links. Props mdawaffe. fixes #3211

git-svn-id: http://svn.automattic.com/wordpress/trunk@4353 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-10-06 22:43:21 +00:00
parent 96e646b5a7
commit f23a961877
2 changed files with 9 additions and 9 deletions

View File

@ -16,10 +16,13 @@ function wp_upload_display( $dims = false, $href = '' ) {
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 +32,10 @@ function wp_upload_display( $dims = false, $href = '' ) {
if ( $href )
$r .= "</a>\n";
$r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='" . get_the_guid() . "' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
if ( $image_src )
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$image_src' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_src' />\n";
if ( isset($width) ) {
$r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
$r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";

View File

@ -1070,11 +1070,8 @@ 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;
function wp_make_link_relative( $link ) {
return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
}
?>