WordPress.org

Make WordPress Core

Changeset 4348


Ignore:
Timestamp:
10/06/2006 12:34:58 AM (12 years ago)
Author:
ryan
Message:

Relativize links. Props mdawaffe.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upload-functions.php

    r4340 r4348  
    1313   
    1414    $class = 'text';
     15    $thumb_src = '';
    1516    $innerHTML = get_attachment_innerHTML( $id, false, $dims );
    1617    if ( $image_src = strstr($innerHTML, 'src="') ) {
    1718        $image_src = explode('"', $image_src);
    1819        $image_src = $image_src[1];
     20        $thumb_src = wp_make_link_relative($image_src);
    1921        $class = 'image';
    20         $innerHTML = ' ' . $innerHTML;
     22        $innerHTML = ' ' . str_replace($image_src, $thumb_src, $innerHTML);
    2123    }
     24
     25    $src = wp_make_link_relative( get_the_guid() );
    2226
    2327    $r = '';
     
    3034        $r .= "</a>\n";
    3135    $r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
    32     $r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='" . get_the_guid() . "' />\n";
     36    $r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
    3337
    3438    if ( $image_src )
    35         $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$image_src' />\n";
     39        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_src' />\n";
    3640    if ( isset($width) ) {
    3741        $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
  • trunk/wp-includes/formatting.php

    r4320 r4348  
    10711071}
    10721072
     1073function wp_make_link_relative( $link, $base = '' ) {
     1074    if ( !$base )
     1075        $base = get_option( 'home' );
     1076    if ( 0 === strpos($link, $base) )
     1077        $link = substr_replace($link, '', 0, strlen($base));
     1078    return $link;
     1079}
    10731080?>
Note: See TracChangeset for help on using the changeset viewer.