WordPress.org

Make WordPress Core

Changeset 4353


Ignore:
Timestamp:
10/06/2006 10:43:21 PM (12 years ago)
Author:
ryan
Message:

Relativize links. Props mdawaffe. fixes #3211

Location:
trunk
Files:
2 edited

Legend:

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

    r4349 r4353  
    1717        $image_src = explode('"', $image_src);
    1818        $image_src = $image_src[1];
     19        $thumb_src = wp_make_link_relative($image_src);
    1920        $class = 'image';
    20         $innerHTML = ' ' . $innerHTML;
     21        $innerHTML = ' ' . str_replace($image_src, $thumb_src, $innerHTML);
    2122    }
     23
     24    $src = wp_make_link_relative( get_the_guid() );
    2225
    2326    $r = '';
     
    3033        $r .= "</a>\n";
    3134    $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";
     35    $r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
    3336
    3437    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";
     38        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_src' />\n";
    3639    if ( isset($width) ) {
    3740        $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
  • trunk/wp-includes/formatting.php

    r4348 r4353  
    10711071}
    10721072
    1073 function 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 }
     1073function wp_make_link_relative( $link ) {
     1074    return preg_replace('|https?://[^/]+(/.*)|i', '$1', $link );
     1075}
     1076
    10801077?>
Note: See TracChangeset for help on using the changeset viewer.