mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Relativize links. Props mdawaffe.
git-svn-id: http://svn.automattic.com/wordpress/trunk@4348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2baac24452
commit
7757b7ff4e
@ -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 .= "</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";
|
||||
|
@ -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;
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user