Make WordPress Core


Ignore:
Timestamp:
10/07/2006 06:31:39 PM (20 years ago)
Author:
ryan
Message:

Inline uploader styling from mdawaffe. fixes #3212

File:
1 edited

Legend:

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

    r4353 r4355  
    1717                $image_src = explode('"', $image_src);
    1818                $image_src = $image_src[1];
    19                 $thumb_src = wp_make_link_relative($image_src);
     19                $image_rel = wp_make_link_relative($image_src);
    2020                $class = 'image';
    21                 $innerHTML = ' ' . str_replace($image_src, $thumb_src, $innerHTML);
     21                $innerHTML = ' ' . str_replace($image_src, $image_rel, $innerHTML);
     22                $image_base = str_replace($image_rel, '', $image_src);
    2223        }
    2324
    24         $src = wp_make_link_relative( get_the_guid() );
     25        $src_base = get_the_guid();
     26        $src = wp_make_link_relative( $src_base );
     27        $src_base = str_replace($src, '', $src_base);
    2528
    2629        $r = '';
     
    3437        $r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
    3538        $r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
    36 
    37         if ( $image_src )
    38                 $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_src' />\n";
     39        $r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";
     40
     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";
    3946        if ( isset($width) ) {
    4047                $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
     
    4956
    5057function wp_upload_view() {
    51         global $style, $post_id;
     58        global $style, $post_id, $style;
    5259        $id = get_the_ID();
    5360        $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
     
    5562        <div id="upload-file">
    5663                <div id="file-title">
    57                         <h2><?php if ( !isset($attachment_data['width']) )
     64                        <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
    5865                                        echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    5966                                the_title();
    60                                 if ( !isset($attachment_data['width']) )
     67                                if ( !isset($attachment_data['width']) && 'inline' != $style )
    6168                                        echo '</a>';
    6269                        ?></h2>
     
    7279
    7380                <div id="upload-file-view" class="alignleft">
    74 <?php           if ( isset($attachment_data['width']) )
     81<?php           if ( isset($attachment_data['width']) && 'inline' != $style )
    7582                        echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    7683                echo wp_upload_display( array(171, 128) );
    77                 if ( isset($attachment_data['width']) )
     84                if ( isset($attachment_data['width']) && 'inline' != $style )
    7885                        echo '</a>'; ?>
    7986                </div>
    8087                <?php the_attachment_links( $id ); ?>
    8188        </div>
    82 <?php
     89<?php   echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' )  . "' /></form>\n";
    8390}
    8491
     
    95102?>
    96103                <div id="file-title">
    97                         <h2><?php if ( !isset($attachment_data['width']) )
     104                        <h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
    98105                                        echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    99106                                the_title();
    100                                 if ( !isset($attachment_data['width']) )
     107                                if ( !isset($attachment_data['width']) && 'inline' != $style )
    101108                                        echo '</a>';
    102109                        ?></h2>
     
    112119
    113120        <div id="upload-file-view" class="alignleft">
    114 <?php           if ( isset($attachment_data['width']) )
     121<?php           if ( isset($attachment_data['width']) && 'inline' != $style )
    115122                        echo "<a href='" . get_the_guid() . "' title='" . __('Direct link to file') . "'>";
    116123                echo wp_upload_display( array(171, 128) );
    117                 if ( isset($attachment_data['width']) )
     124                if ( isset($attachment_data['width']) && 'inline' != $style )
    118125                        echo '</a>'; ?>
    119126        </div>
    120127<?php   endif; ?>
    121                 <table>
    122 <?php   if ( !$id ): ?>
     128                <table><col /><col class="widefat" />
     129<?php   if ( $id ): ?>
    123130                        <tr>
    124                                 <th scope="row"><label for="upload"><?php _e('File:'); ?></label></th>
     131                                <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>
     133                        </tr>
     134<?php   else : ?>
     135                        <tr>
     136                                <th scope="row"><label for="upload"><?php _e('File'); ?></label></th>
    125137                                <td><input type="file" id="upload" name="image" /></td>
    126138                        </tr>
    127139<?php   endif; ?>
    128140                        <tr>
    129                                 <th scope="row"><label for="post_title"><?php _e('Title:'); ?></label></th>
     141                                <th scope="row"><label for="post_title"><?php _e('Title'); ?></label></th>
    130142                                <td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
    131143                        </tr>
    132144                        <tr>
    133                                 <th scope="row"><label for="post_content"><?php _e('Description:'); ?></label></th>
     145                                <th scope="row"><label for="post_content"><?php _e('Description'); ?></label></th>
    134146                                <td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
    135147                        </tr>
    136                         <tr id="buttons">
    137                                 <th></th>
    138                                 <td>
     148                        <tr id="buttons" class="submit">
     149                                <td colspan='2'>
     150<?php   if ( $id ) : ?>
     151                                        <input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" />
     152<?php   endif; ?>
    139153                                        <input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
    140154                                        <input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
     
    147161                                        <div class="submit">
    148162                                                <input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?> &raquo;" />
    149 <?php   if ( $id ) : ?>
    150                                                 <input type="submit" name="delete" class="delete" value="<?php _e('Delete'); ?>" />
    151 <?php   endif; ?>
    152163                                        </div>
    153164                                </td>
     
    353364        if ( 'inline' == @$_GET['style'] ) {
    354365                echo "<style type='text/css'>\n";
    355                 echo "\tbody { height: 14em; overflow: hidden; }\n";
     366                echo "\tbody { height: 15em; overflow: hidden; }\n";
    356367                echo "\t#upload-content { overflow-y: auto; }\n";
    357368                echo "\t#upload-file { position: absolute; }\n";
Note: See TracChangeset for help on using the changeset viewer.