Make WordPress Core


Ignore:
Timestamp:
01/02/2007 07:28:30 PM (18 years ago)
Author:
ryan
Message:

Attachment fixes from mdawaffe. fixes #3411

File:
1 edited

Legend:

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

    r4657 r4670  
    1414    $class = 'text';
    1515    $innerHTML = get_attachment_innerHTML( $id, false, $dims );
    16     if ( $image_src = strstr($innerHTML, 'src=') ) {
    17         preg_match("/src=(\"|')(.+?)\\1/", $image_src, $matches);
    18         $image_src = $matches[2];
     16    if ( $image_src = get_attachment_icon_src() ) {
    1917        $image_rel = wp_make_link_relative($image_src);
     18        $innerHTML = ' ' . str_replace($image_src, $image_rel, $innerHTML);
    2019        $class = 'image';
    21         $innerHTML = ' ' . str_replace($image_src, $image_rel, $innerHTML);
    22         $image_base = str_replace($image_rel, '', $image_src);
    2320    }
    2421
    25     $src_base = get_the_guid();
     22    $src_base = wp_get_attachment_url();
    2623    $src = wp_make_link_relative( $src_base );
    2724    $src_base = str_replace($src, '', $src_base);
     
    3936    $r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";
    4037
    41     if ( isset($attachment_data['thumb']) ) {
    42         $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$image_rel' />\n";
    43         $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$image_base' />\n";
    44     } elseif ( $image_rel )
    45         $r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='1' />\n";
     38    if ( !$thumb_base = wp_get_attachment_thumb_url() )
     39        $thumb_base = wp_mime_type_icon();
     40    if ( $thumb_base ) {
     41        $thumb_rel = wp_make_link_relative( $thumb_base );
     42        $thumb_base = str_replace( $thumb_rel, '', $thumb_base );
     43        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_rel' />\n";
     44        $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$thumb_base' />\n";
     45    }
     46    $is_image = (int) wp_attachment_is_image();
     47    $r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='$is_image' />\n";
    4648    if ( isset($width) ) {
    4749        $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
     
    6365        <div id="file-title">
    6466            <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
    65                     echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
     67                    echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
    6668                the_title();
    6769                if ( !isset($attachment_data['width']) && 'inline' != $style )
     
    8082        <div id="upload-file-view" class="alignleft">
    8183<?php       if ( isset($attachment_data['width']) && 'inline' != $style )
    82             echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
     84            echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
    8385        echo wp_upload_display( array(171, 128) );
    8486        if ( isset($attachment_data['width']) && 'inline' != $style )
     
    103105        <div id="file-title">
    104106            <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
    105                     echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
     107                    echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
    106108                the_title();
    107109                if ( !isset($attachment_data['width']) && 'inline' != $style )
     
    120122    <div id="upload-file-view" class="alignleft">
    121123<?php       if ( isset($attachment_data['width']) && 'inline' != $style )
    122             echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
     124            echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
    123125        echo wp_upload_display( array(171, 128) );
    124126        if ( isset($attachment_data['width']) && 'inline' != $style )
     
    130132            <tr>
    131133                <th scope="row"><label for="url"><?php _e('URL'); ?></label></th>
    132                 <td><input type="text" id="url" class="readonly" value="<?php the_guid(); ?>" readonly="readonly" /></td>
     134                <td><input type="text" id="url" class="readonly" value="<?php echo wp_get_attachment_url(); ?>" readonly="readonly" /></td>
    133135            </tr>
    134136<?php   else : ?>
     
    344346    }
    345347}
    346 
Note: See TracChangeset for help on using the changeset viewer.