From 12c658330683a07b6f51150510538138f5213977 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 7 Oct 2006 18:31:39 +0000 Subject: [PATCH] Inline uploader styling from mdawaffe. fixes #3212 git-svn-id: http://svn.automattic.com/wordpress/trunk@4355 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-functions.php | 28 +++++++++------ wp-admin/upload-functions.php | 65 ++++++++++++++++++++--------------- wp-admin/upload-js.php | 62 +++++++++++++++++++++------------ wp-admin/upload.css | 13 +++---- wp-admin/wp-admin.css | 4 +-- 5 files changed, 105 insertions(+), 67 deletions(-) diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 083a07a11..fe222adc6 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -1969,27 +1969,35 @@ function the_attachment_links($id = false) { return false; $icon = get_attachment_icon($post->ID); - + $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true ); + $thumb = isset($attachment_data['thumb']); ?> diff --git a/wp-admin/upload-functions.php b/wp-admin/upload-functions.php index 927873ff3..d0fb32cdf 100644 --- a/wp-admin/upload-functions.php +++ b/wp-admin/upload-functions.php @@ -16,12 +16,15 @@ function wp_upload_display( $dims = false, $href = '' ) { if ( $image_src = strstr($innerHTML, 'src="') ) { $image_src = explode('"', $image_src); $image_src = $image_src[1]; - $thumb_src = wp_make_link_relative($image_src); + $image_rel = wp_make_link_relative($image_src); $class = 'image'; - $innerHTML = ' ' . str_replace($image_src, $thumb_src, $innerHTML); + $innerHTML = ' ' . str_replace($image_src, $image_rel, $innerHTML); + $image_base = str_replace($image_rel, '', $image_src); } - $src = wp_make_link_relative( get_the_guid() ); + $src_base = get_the_guid(); + $src = wp_make_link_relative( $src_base ); + $src_base = str_replace($src, '', $src_base); $r = ''; @@ -33,9 +36,13 @@ function wp_upload_display( $dims = false, $href = '' ) { $r .= "\n"; $r .= "\n\t\t
\n\t\t\t

\n"; $r .= "\t\t\t\t\n"; + $r .= "\t\t\t\t\n"; - if ( $image_src ) - $r .= "\t\t\t\t\n"; + if ( isset($attachment_data['thumb']) ) { + $r .= "\t\t\t\t\n"; + $r .= "\t\t\t\t\n"; + } elseif ( $image_rel ) + $r .= "\t\t\t\t\n"; if ( isset($width) ) { $r .= "\t\t\t\t\n"; $r .= "\t\t\t\t\n"; @@ -48,16 +55,16 @@ function wp_upload_display( $dims = false, $href = '' ) { } function wp_upload_view() { - global $style, $post_id; + global $style, $post_id, $style; $id = get_the_ID(); $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true ); ?>

-

"; the_title(); - if ( !isset($attachment_data['width']) ) + if ( !isset($attachment_data['width']) && 'inline' != $style ) echo ''; ?>

-"; echo wp_upload_display( array(171, 128) ); - if ( isset($attachment_data['width']) ) + if ( isset($attachment_data['width']) && 'inline' != $style ) echo ''; ?>
-\n"; } function wp_upload_form() { @@ -94,10 +101,10 @@ function wp_upload_form() { $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true ); ?>
-

"; the_title(); - if ( !isset($attachment_data['width']) ) + if ( !isset($attachment_data['width']) && 'inline' != $style ) echo ''; ?>

-"; echo wp_upload_display( array(171, 128) ); - if ( isset($attachment_data['width']) ) + if ( isset($attachment_data['width']) && 'inline' != $style ) echo ''; ?>
- - +
+ - + + + + + + - + - + - - - + @@ -352,7 +363,7 @@ function wp_upload_admin_head() { echo "\n"; if ( 'inline' == @$_GET['style'] ) { echo ""; diff --git a/wp-admin/upload-js.php b/wp-admin/upload-js.php index 60d04cd23..8b01361b3 100644 --- a/wp-admin/upload-js.php +++ b/wp-admin/upload-js.php @@ -37,11 +37,18 @@ addLoadEvent( function() { if ( id == this.currentImage.ID ) return; var thumbEl = $('attachment-thumb-url-' + id); - if ( thumbEl ) + this.currentImage.isImage = true; + if ( thumbEl ) { this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value ); - else + this.currentImage.thumbBase = ( 0 == id ? '' : $('attachment-thumb-url-base-' + id).value ); + } else { this.currentImage.thumb = false; + var isImageEl = $('attachment-is-image-' + id); + if ( !isImageEl ) + this.currentImage.isImage = false; + } this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value ); + this.currentImage.srcBase = ( 0 == id ? '' : $('attachment-url-base-' + id).value ); this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value ); this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value ); this.currentImage.description = ( 0 == id ? '' : $('attachment-description-' + id).value ); @@ -65,13 +72,13 @@ addLoadEvent( function() { var params = $H(this.params); params.ID = ''; params.action = ''; - h += "« Back"; + h += "« Back"; } else { h += "« Back"; } h += "
" - if ( !this.currentImage.thumb ) - h += "

" + this.currentImage.title + "

"; + if ( !this.currentImage.isImage ) + h += "

" + this.currentImage.title + "

"; else h += "

" + this.currentImage.title + "

"; h += " — "; @@ -79,9 +86,11 @@ addLoadEvent( function() { h += ""; h += '
' h += "
"; - if ( this.currentImage.thumb ) - h += "" + this.currentImage.title + ""; - else + if ( this.currentImage.isImage ) { + h += ""; + h += "" + this.currentImage.title + ""; + h += ""; + } else h += ' '; h += "
"; @@ -119,6 +128,7 @@ addLoadEvent( function() { var action = 'upload.php?style=' + this.style + '&tab=upload'; if ( this.postID ) action += '&post_id=' + this.postID; + h += ""; if ( this.ID ) { var params = $H(this.params); @@ -129,8 +139,8 @@ addLoadEvent( function() { h += "« Back"; } h += "
" - if ( !this.currentImage.thumb ) - h += "

" + this.currentImage.title + "

"; + if ( !this.currentImage.isImage ) + h += "

" + this.currentImage.title + "

"; else h += "

" + this.currentImage.title + "

"; h += " — "; @@ -138,26 +148,31 @@ addLoadEvent( function() { h += ""; h += '
' h += "
"; - if ( this.currentImage.thumb ) - h += "" + this.currentImage.title + ""; - else + if ( this.currentImage.isImage ) { + h += ""; + h += "" + this.currentImage.title + ""; + h += ""; + } else h += ' '; h += "
"; - h += "
+
+ + + @@ -146,9 +160,6 @@ function wp_upload_form() {
- - -
" - h += ""; + h += "
" + h += ""; + h += ""; + h += ""; + h += ""; h += ""; h += ""; - h += ""; + h += ""; h += ""; - h += "
"; + h += "
"; h += ""; h += ""; h += ""; h += ""; - h += "
"; - h += "
"; + h += "
"; + h += ""; new Insertion.Top('upload-content', h); if (e) Event.stop(e); @@ -202,11 +217,13 @@ addLoadEvent( function() { displayEl = $A(document.forms.uploadoptions.elements.display).detect( function(i) { return i.checked; } ) if ( displayEl ) display = displayEl.value; + else if ( this.currentImage.isImage ) + display = 'full'; if ( 'none' != link ) - h += ""; + h += ""; if ( display ) - h += "" + this.currentImage.title + ""; + h += "" + this.currentImage.title + ""; else h += this.currentImage.title; if ( 'none' != link ) @@ -220,7 +237,8 @@ addLoadEvent( function() { win.tinyMCE.execCommand('mceInsertContent', false, h); else win.edInsertContent(win.edCanvas, h); - this.cancelView(); + if ( !this.ID ) + this.cancelView(); return false; }, diff --git a/wp-admin/upload.css b/wp-admin/upload.css index 25f1c089a..3517cee05 100644 --- a/wp-admin/upload.css +++ b/wp-admin/upload.css @@ -57,17 +57,18 @@ body { background: #f9fcfe; } margin: 0 auto; top: 0; left: 0; - width: 45em; + width: 95%; height: 100%; background: #f9fcfe; } -#upload-file th { + +#uupload-file th { width: 8em; } form#upload-file input, form#upload-file textarea, div#upload-content.upload table { width: 100%; } -form#upload-file div.submit input { width: auto; } +form#upload-file .submit input { width: auto; } #upload-file-view { padding: 0 0 0 75px; } @@ -134,8 +135,6 @@ h2 { #upload-files a.file-link img { vertical-align: middle; } -#the-attachment-links { float: right; } - #the-attachment-links textarea { font-size: 10px; overflow: hidden; @@ -172,4 +171,6 @@ tr, td, th { #uploadoptions table { width: 300px; -} \ No newline at end of file +} + +input.readonly { background-color: #ddd; } diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 4dfe69e75..039fb6ff4 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -206,7 +206,7 @@ textarea, input, select { border-style: none; padding: 0px; margin-bottom: 16px; - height: 16em; + height: 17em; width: 100%; /* overflow-y: hidden;*/ } @@ -1318,4 +1318,4 @@ a.page-numbers:hover { .page-numbers.current { border: 1px solid #999; font-weight: bold; -} \ No newline at end of file +}