Ticket #5609: media-upload-r6577.patch
File media-upload-r6577.patch, 34.2 KB (added by , 17 years ago) |
---|
-
wp-includes/js/thickbox/thickbox.css
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-includes/js/thickbox/loadingAnimation.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
1 /* ----------------------------------------------------------------------------------------------------------------*/ 2 /* ---------->>> global settings needed for thickbox <<<-----------------------------------------------------------*/ 3 /* ----------------------------------------------------------------------------------------------------------------*/ 4 *{padding: 0; margin: 0;} 5 6 /* ----------------------------------------------------------------------------------------------------------------*/ 7 /* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/ 8 /* ----------------------------------------------------------------------------------------------------------------*/ 9 #TB_window { 10 font: 12px Arial, Helvetica, sans-serif; 11 color: #333333; 12 } 13 14 #TB_secondLine { 15 font: 10px Arial, Helvetica, sans-serif; 16 color:#666666; 17 } 18 19 #TB_window a:link {color: #666666;} 20 #TB_window a:visited {color: #666666;} 21 #TB_window a:hover {color: #000;} 22 #TB_window a:active {color: #666666;} 23 #TB_window a:focus{color: #666666;} 24 25 /* ----------------------------------------------------------------------------------------------------------------*/ 26 /* ---------->>> thickbox settings <<<-----------------------------------------------------------------------------*/ 27 /* ----------------------------------------------------------------------------------------------------------------*/ 28 #TB_overlay { 29 position: fixed; 30 z-index:100; 31 top: 0px; 32 left: 0px; 33 height:100%; 34 width:100%; 35 } 36 37 .TB_overlayMacFFBGHack {background: url(macFFBgHack.png) repeat;} 38 .TB_overlayBG { 39 background-color:#000; 40 filter:alpha(opacity=75); 41 -moz-opacity: 0.75; 42 opacity: 0.75; 43 } 44 45 * html #TB_overlay { /* ie6 hack */ 46 position: absolute; 47 height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); 48 } 49 50 #TB_window { 51 position: fixed; 52 background: #ffffff; 53 z-index: 102; 54 color:#000000; 55 display:none; 56 border: 4px solid #525252; 57 text-align:left; 58 top:50%; 59 left:50%; 60 } 61 62 * html #TB_window { /* ie6 hack */ 63 position: absolute; 64 margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); 65 } 66 67 #TB_window img#TB_Image { 68 display:block; 69 margin: 15px 0 0 15px; 70 border-right: 1px solid #ccc; 71 border-bottom: 1px solid #ccc; 72 border-top: 1px solid #666; 73 border-left: 1px solid #666; 74 } 75 76 #TB_caption{ 77 height:25px; 78 padding:7px 30px 10px 25px; 79 float:left; 80 } 81 82 #TB_closeWindow{ 83 height:25px; 84 padding:11px 25px 10px 0; 85 float:right; 86 } 87 88 #TB_closeAjaxWindow{ 89 padding:7px 10px 5px 0; 90 margin-bottom:1px; 91 text-align:right; 92 float:right; 93 } 94 95 #TB_ajaxWindowTitle{ 96 float:left; 97 padding:7px 0 5px 10px; 98 margin-bottom:1px; 99 } 100 101 #TB_title{ 102 background-color:#e8e8e8; 103 height:27px; 104 } 105 106 #TB_ajaxContent{ 107 clear:both; 108 padding:2px 15px 15px 15px; 109 overflow:auto; 110 text-align:left; 111 line-height:1.4em; 112 } 113 114 #TB_ajaxContent.TB_modal{ 115 padding:15px; 116 } 117 118 #TB_ajaxContent p{ 119 padding:5px 0px 5px 0px; 120 } 121 122 #TB_load{ 123 position: fixed; 124 display:none; 125 height:13px; 126 width:208px; 127 z-index:103; 128 top: 50%; 129 left: 50%; 130 margin: -6px 0 0 -104px; /* -height/2 0 0 -width/2 */ 131 } 132 133 * html #TB_load { /* ie6 hack */ 134 position: absolute; 135 margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px'); 136 } 137 138 #TB_HideSelect{ 139 z-index:99; 140 position:fixed; 141 top: 0; 142 left: 0; 143 background-color:#fff; 144 border:none; 145 filter:alpha(opacity=0); 146 -moz-opacity: 0; 147 opacity: 0; 148 height:100%; 149 width:100%; 150 } 151 152 * html #TB_HideSelect { /* ie6 hack */ 153 position: absolute; 154 height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); 155 } 156 157 #TB_iframeContent{ 158 clear:both; 159 border:none; 160 margin-bottom:-1px; 161 margin-top:1px; 162 _margin-bottom:1px; 163 } -
wp-includes/js/thickbox/thickbox.js
1 /* 2 * Thickbox 3.1 - One Box To Rule Them All. 3 * By Cody Lindley (http://www.codylindley.com) 4 * Copyright (c) 2007 cody lindley 5 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php 6 */ 7 8 var tb_pathToImage = "../wp-includes/js/thickbox/loadingAnimation.gif"; 9 var tb_closeImage = "../wp-includes/js/thickbox/tb-close.png"; 10 11 /*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ 12 13 //on page load call tb_init 14 addLoadEvent(function(){ 15 tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox 16 imgLoader = new Image();// preload image 17 imgLoader.src = tb_pathToImage; 18 }); 19 20 //add thickbox to href & area elements that have a class of .thickbox 21 function tb_init(domChunk){ 22 jQuery(domChunk).click(function(){ 23 var t = this.title || this.name || null; 24 var a = this.href || this.alt; 25 var g = this.rel || false; 26 tb_show(t,a,g); 27 this.blur(); 28 return false; 29 }); 30 } 31 32 function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link 33 34 try { 35 if (typeof document.body.style.maxHeight === "undefined") {//if IE 6 36 jQuery("body","html").css({height: "100%", width: "100%"}); 37 jQuery("html").css("overflow","hidden"); 38 if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6 39 jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>"); 40 jQuery("#TB_overlay").click(tb_remove); 41 } 42 }else{//all others 43 if(document.getElementById("TB_overlay") === null){ 44 jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>"); 45 jQuery("#TB_overlay").click(tb_remove); 46 } 47 } 48 49 if(tb_detectMacXFF()){ 50 jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash 51 }else{ 52 jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity 53 } 54 55 if(caption===null){caption="";} 56 jQuery("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page 57 jQuery('#TB_load').show();//show loader 58 59 var baseURL; 60 if(url.indexOf("?")!==-1){ //ff there is a query string involved 61 baseURL = url.substr(0, url.indexOf("?")); 62 }else{ 63 baseURL = url; 64 } 65 66 var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; 67 var urlType = baseURL.toLowerCase().match(urlString); 68 69 if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images 70 71 TB_PrevCaption = ""; 72 TB_PrevURL = ""; 73 TB_PrevHTML = ""; 74 TB_NextCaption = ""; 75 TB_NextURL = ""; 76 TB_NextHTML = ""; 77 TB_imageCount = ""; 78 TB_FoundURL = false; 79 if(imageGroup){ 80 TB_TempArray = jQuery("a[@rel="+imageGroup+"]").get(); 81 for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) { 82 var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); 83 if (!(TB_TempArray[TB_Counter].href == url)) { 84 if (TB_FoundURL) { 85 TB_NextCaption = TB_TempArray[TB_Counter].title; 86 TB_NextURL = TB_TempArray[TB_Counter].href; 87 TB_NextHTML = "<span id='TB_next'> <a href='#'>Next ></a></span>"; 88 } else { 89 TB_PrevCaption = TB_TempArray[TB_Counter].title; 90 TB_PrevURL = TB_TempArray[TB_Counter].href; 91 TB_PrevHTML = "<span id='TB_prev'> <a href='#'>< Prev</a></span>"; 92 } 93 } else { 94 TB_FoundURL = true; 95 TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length); 96 } 97 } 98 } 99 100 imgPreloader = new Image(); 101 imgPreloader.onload = function(){ 102 imgPreloader.onload = null; 103 104 // Resizing large images - orginal by Christian Montoya edited by me. 105 var pagesize = tb_getPageSize(); 106 var x = pagesize[0] - 150; 107 var y = pagesize[1] - 150; 108 var imageWidth = imgPreloader.width; 109 var imageHeight = imgPreloader.height; 110 if (imageWidth > x) { 111 imageHeight = imageHeight * (x / imageWidth); 112 imageWidth = x; 113 if (imageHeight > y) { 114 imageWidth = imageWidth * (y / imageHeight); 115 imageHeight = y; 116 } 117 } else if (imageHeight > y) { 118 imageWidth = imageWidth * (y / imageHeight); 119 imageHeight = y; 120 if (imageWidth > x) { 121 imageHeight = imageHeight * (x / imageWidth); 122 imageWidth = x; 123 } 124 } 125 // End Resizing 126 127 TB_WIDTH = imageWidth + 30; 128 TB_HEIGHT = imageHeight + 60; 129 jQuery("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div>"); 130 131 jQuery("#TB_closeWindowButton").click(tb_remove); 132 133 if (!(TB_PrevHTML === "")) { 134 function goPrev(){ 135 if(jQuery(document).unbind("click",goPrev)){jQuery(document).unbind("click",goPrev);} 136 jQuery("#TB_window").remove(); 137 jQuery("body").append("<div id='TB_window'></div>"); 138 tb_show(TB_PrevCaption, TB_PrevURL, imageGroup); 139 return false; 140 } 141 jQuery("#TB_prev").click(goPrev); 142 } 143 144 if (!(TB_NextHTML === "")) { 145 function goNext(){ 146 jQuery("#TB_window").remove(); 147 jQuery("body").append("<div id='TB_window'></div>"); 148 tb_show(TB_NextCaption, TB_NextURL, imageGroup); 149 return false; 150 } 151 jQuery("#TB_next").click(goNext); 152 153 } 154 155 document.onkeydown = function(e){ 156 if (e == null) { // ie 157 keycode = event.keyCode; 158 } else { // mozilla 159 keycode = e.which; 160 } 161 if(keycode == 27){ // close 162 tb_remove(); 163 } else if(keycode == 190){ // display previous image 164 if(!(TB_NextHTML == "")){ 165 document.onkeydown = ""; 166 goNext(); 167 } 168 } else if(keycode == 188){ // display next image 169 if(!(TB_PrevHTML == "")){ 170 document.onkeydown = ""; 171 goPrev(); 172 } 173 } 174 }; 175 176 tb_position(); 177 jQuery("#TB_load").remove(); 178 jQuery("#TB_ImageOff").click(tb_remove); 179 jQuery("#TB_window").css({display:"block"}); //for safari using css instead of show 180 }; 181 182 imgPreloader.src = url; 183 }else{//code to show html 184 185 var queryString = url.replace(/^[^\?]+\??/,''); 186 var params = tb_parseQuery( queryString ); 187 188 TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL 189 TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL 190 ajaxContentW = TB_WIDTH - 30; 191 ajaxContentH = TB_HEIGHT - 45; 192 193 if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window 194 urlNoQuery = url.split('TB_'); 195 jQuery("#TB_iframeContent").remove(); 196 if(params['modal'] != "true"){//iframe no modal 197 jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'><img src='" + tb_closeImage + "' /></a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>"); 198 }else{//iframe modal 199 jQuery("#TB_overlay").unbind(); 200 jQuery("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>"); 201 } 202 }else{// not an iframe, ajax 203 if(jQuery("#TB_window").css("display") != "block"){ 204 if(params['modal'] != "true"){//ajax no modal 205 jQuery("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'><img src='" + tb_closeImage + "' /></a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>"); 206 }else{//ajax modal 207 jQuery("#TB_overlay").unbind(); 208 jQuery("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>"); 209 } 210 }else{//this means the window is already up, we are just loading new content via ajax 211 jQuery("#TB_ajaxContent")[0].style.width = ajaxContentW +"px"; 212 jQuery("#TB_ajaxContent")[0].style.height = ajaxContentH +"px"; 213 jQuery("#TB_ajaxContent")[0].scrollTop = 0; 214 jQuery("#TB_ajaxWindowTitle").html(caption); 215 } 216 } 217 218 jQuery("#TB_closeWindowButton").click(tb_remove); 219 220 if(url.indexOf('TB_inline') != -1){ 221 jQuery("#TB_ajaxContent").append(jQuery('#' + params['inlineId']).children()); 222 jQuery("#TB_window").unload(function () { 223 jQuery('#' + params['inlineId']).append( jQuery("#TB_ajaxContent").children() ); // move elements back when you're finished 224 }); 225 tb_position(); 226 jQuery("#TB_load").remove(); 227 jQuery("#TB_window").css({display:"block"}); 228 }else if(url.indexOf('TB_iframe') != -1){ 229 tb_position(); 230 if($.browser.safari){//safari needs help because it will not fire iframe onload 231 jQuery("#TB_load").remove(); 232 jQuery("#TB_window").css({display:"block"}); 233 } 234 }else{ 235 jQuery("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method 236 tb_position(); 237 jQuery("#TB_load").remove(); 238 tb_init("#TB_ajaxContent a.thickbox"); 239 jQuery("#TB_window").css({display:"block"}); 240 }); 241 } 242 243 } 244 245 if(!params['modal']){ 246 document.onkeyup = function(e){ 247 if (e == null) { // ie 248 keycode = event.keyCode; 249 } else { // mozilla 250 keycode = e.which; 251 } 252 if(keycode == 27){ // close 253 tb_remove(); 254 } 255 }; 256 } 257 258 } catch(e) { 259 //nothing here 260 } 261 } 262 263 //helper functions below 264 function tb_showIframe(){ 265 jQuery("#TB_load").remove(); 266 jQuery("#TB_window").css({display:"block"}); 267 } 268 269 function tb_remove() { 270 jQuery("#TB_imageOff").unbind("click"); 271 jQuery("#TB_closeWindowButton").unbind("click"); 272 jQuery("#TB_window").fadeOut("fast",function(){jQuery('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();}); 273 jQuery("#TB_load").remove(); 274 if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 275 jQuery("body","html").css({height: "auto", width: "auto"}); 276 jQuery("html").css("overflow",""); 277 } 278 document.onkeydown = ""; 279 document.onkeyup = ""; 280 return false; 281 } 282 283 function tb_position() { 284 jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'}); 285 if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6 286 jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'}); 287 } 288 } 289 290 function tb_parseQuery ( query ) { 291 var Params = {}; 292 if ( ! query ) {return Params;}// return empty object 293 var Pairs = query.split(/[;&]/); 294 for ( var i = 0; i < Pairs.length; i++ ) { 295 var KeyVal = Pairs[i].split('='); 296 if ( ! KeyVal || KeyVal.length != 2 ) {continue;} 297 var key = unescape( KeyVal[0] ); 298 var val = unescape( KeyVal[1] ); 299 val = val.replace(/\+/g, ' '); 300 Params[key] = val; 301 } 302 return Params; 303 } 304 305 function tb_getPageSize(){ 306 var de = document.documentElement; 307 var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; 308 var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; 309 arrayPageSize = [w,h]; 310 return arrayPageSize; 311 } 312 313 function tb_detectMacXFF() { 314 var userAgent = navigator.userAgent.toLowerCase(); 315 if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { 316 return true; 317 } 318 } 319 320 -
wp-includes/script-loader.php
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-includes/js/thickbox/tb-close.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
84 84 $this->add( 'dimensions', '/wp-includes/js/jquery/jquery.dimensions.min.js', array('jquery'), '1.1.2'); 85 85 $this->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('dimensions'), '1.1'); 86 86 $this->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20'); 87 $this->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1'); 87 88 88 89 if ( is_admin() ) { 89 90 $this->add( 'ajaxcat', '/wp-admin/js/cat.js', array( 'wp-lists' ), '20071101' ); … … 107 108 $this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' ); 108 109 $this->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' ); 109 110 $this->add( 'post', '/wp-admin/js/post.js', array('suggest'), '20080102' ); 111 $this->add( 'media-upload', '/wp-admin/js/media-upload.js', false, '20080109' ); 110 112 $this->localize( 'upload', 'uploadL10n', array( 111 113 'browseTitle' => attribute_escape(__('Browse your files')), 112 114 'back' => __('« Back'), -
wp-admin/post-new.php
5 5 $editing = true; 6 6 wp_enqueue_script('autosave'); 7 7 wp_enqueue_script('post'); 8 wp_enqueue_script('thickbox'); 9 wp_enqueue_script('media-upload'); 8 10 9 11 require_once ('./admin-header.php'); 10 12 -
wp-admin/includes/media.php
1 <?php 2 3 function image_upload_tabs() { 4 $_default_tabs = array( 5 'image_upload_handler' => __('From Computer'), // handler function name => tab text 6 ); 7 8 return apply_filters('image_upload_tabs', $_default_tabs); 9 } 10 11 function image_upload_form( $action_url, $values = array(), $error = null ) { 12 $action_url = attribute_escape( $action_url ); 13 $image_alt = attribute_escape( @$values['image-alt'] ); 14 $image_url = attribute_escape( @$values['image-url'] ); 15 $image_title = attribute_escape( @$values['image-title'] ); 16 $image_align = @$values['image-url']; 17 18 ?> 19 <div id="media-upload-header"> 20 <h3>Add Image</h3> 21 <ul id="media-upload-tabs"> 22 <li><?php _e('From Computer'); ?></li> 23 <li><?php _e('Media Library'); ?></li> 24 <li class="last"><?php _e('Flickr'); ?></li> 25 </ul> 26 </div> 27 <?php if ($error) { ?> 28 <div id="media-upload-error"> 29 <?php echo $error->get_error_message(); ?> 30 </div> 31 <?php } ?> 32 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($action_url); ?>" id="image-upload" class="media-upload-form"> 33 <p><label for="image-file"><?php _e('Choose image'); ?></label> 34 <input type="file" name="image-file" id="image-file" /> 35 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label></p> 36 <p><label for="image-alt" class="required"><?php _e('<alt> (required)'); ?></label> 37 <input type="text" name="image-alt" id="image-alt" /> 38 <label for="image-alt" class="form-help"><?php _e('e.g., The Mona Lisa'); ?></label></p> 39 <p><label for="image-url"><?php _e('URL'); ?></label> 40 <input type="text" name="image-url" id="image-url" /> 41 <label for="image-url" class="form-help"><?php _e('e.g., http://www.wordpress.org/'); ?></label></p> 42 <p><label for="image-title"><?php _e('<title>'); ?></label> 43 <input type="text" name="image-title" id="image-title" /> 44 <label for="image-url" class="form-help"><?php _e('e.g., The Mona Lisa, one of many paintings in the Lourve'); ?></label></p> 45 <fieldset id="image-align"> 46 <legend><?php _e('Alignment'); ?></legend> 47 <input type="radio" name="image-align" id="image-align-none" value="none" <?php if ($image_align == 'none' || !$image_align) echo ' checked="checked"'; ?>/> 48 <label for="image-align-none" id="image-align-none-label"><?php _e('None'); ?></label> 49 <input type="radio" name="image-align" id="image-align-left" value="left" <?php if ($image_align == 'left') echo ' checked="checked"'; ?>/> 50 <label for="image-align-left" id="image-align-left-label"><?php _e('Left'); ?></label> 51 <input type="radio" name="image-align" id="image-align-center" value="center" <?php if ($image_align == 'center') echo ' checked="checked"'; ?>/> 52 <label for="image-align-center" id="image-align-center-label"><?php _e('Center'); ?></label> 53 <input type="radio" name="image-align" id="image-align-right" value="right" <?php if ($image_align == 'right') echo ' checked="checked"'; ?>/> 54 <label for="image-align-right" id="image-align-right-label"><?php _e('Right'); ?></label> 55 </fieldset> 56 <p> 57 <button name="image-add" id="image-add" class="button-ok" value="1"><?php _e('Add Image'); ?></button> 58 <a href="#" onclick="return top.tb_remove();" id="image-cancel" class="button-cancel"><?php _e('Cancel'); ?></a> 59 </p> 60 <input type="hidden" name="parent_post_id" value="<?php echo attribute_escape('parent_post_id'); ?>" /> 61 <?php wp_nonce_field( 'inlineuploading' ); ?> 62 </form> 63 <?php 64 } 65 66 function image_upload_handler() { 67 68 if ( !current_user_can('upload_files') ) { 69 return new wp_error( 'upload_not_allowed', __('You are not allowed to upload files.') ); 70 } 71 72 check_admin_referer('inlineuploading'); 73 74 if ( empty($_POST['image-add']) ) { 75 // no button click, we're just displaying the form 76 wp_iframe( 'image_upload_form', get_option('siteurl') . '/wp-admin/media-upload.php?type=image' ); 77 } 78 else { 79 // Add Image button was clicked 80 $id = image_upload_post(); 81 82 // if the input was invalid, redisplay the form with its current values 83 if ( is_wp_error($id) ) 84 wp_iframe( 'image_upload_form', get_option('siteurl') . '/wp-admin/media-upload.php?type=image', $_POST, $id ); 85 else { 86 image_send_to_editor($id, $_POST['image-alt'], $_POST['image-title'], $_POST['image-align'], $_POST['image-url']); 87 } 88 } 89 } 90 91 function image_send_to_editor($id, $alt, $title, $align, $url='') { 92 93 $img_src = wp_get_attachment_url($id); 94 $meta = wp_get_attachment_metadata($id); 95 96 $hwstring = ''; 97 if ( isset($meta['width'], $meta['height']) ) 98 $hwstring = ' width="'.intval($meta['width']).'" height="'.intval($meta['height']).'"'; 99 100 $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'"'.$hwstring.' class="align-'.attribute_escape($align).'" />'; 101 102 if ( $url ) 103 $html = '<a href="'.attribute_escape($url).'">'.$html.'</a>'; 104 105 media_send_to_editor($html); 106 } 107 108 function media_send_to_editor($html) { 109 ?> 110 <script type="text/javascript"> 111 <!-- 112 top.send_to_editor('<?php echo addslashes($html); ?>'); 113 top.tb_remove(); 114 --> 115 </script> 116 <?php 117 } 118 119 // this handles the file upload POST itself, validating input and inserting the file if it's valid 120 function image_upload_post() { 121 if ( empty($_FILES['image-file']['name']) ) 122 return new wp_error( 'image_file_required', __('Please choose an image file to upload') ); 123 if ( empty($_POST['image-alt']) ) 124 return new wp_error( 'image_alt_required', __('Please enter an <alt> description') ); 125 126 $overrides = array('test_form'=>false); 127 $file = wp_handle_upload($_FILES['image-file'], $overrides); 128 129 if ( isset($file['error']) ) 130 return new wp_error( 'upload_error', $file['error'] ); 131 132 $url = $file['url']; 133 $type = $file['type']; 134 $file = $file['file']; 135 136 $post_title = trim($_POST['image-title']); 137 $post_content = trim($_POST['image-alt']); 138 $post_parent = intval($_POST['parent_post_id']); 139 140 // Construct the attachment array 141 $attachment = array( 142 'post_title' => $post_title, 143 'post_content' => $post_content, 144 'post_type' => 'attachment', 145 'post_parent' => $post_parent, 146 'post_mime_type' => $type, 147 'guid' => $url 148 ); 149 150 // Save the data 151 $id = wp_insert_attachment($attachment, $file, $post_parent); 152 if ( !is_wp_error($id) ) 153 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 154 155 return $id; 156 157 wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id"); 158 159 } 160 161 // wrap iframe content (produced by $content_func) in a doctype, html head/body etc 162 // any additional function args will be passed to content_func 163 function wp_iframe($content_func /* ... */) { 164 ?> 165 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 166 <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>> 167 <head> 168 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 169 <title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — WordPress</title> 170 <?php wp_admin_css(); ?> 171 <script type="text/javascript"> 172 //<![CDATA[ 173 function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}} 174 //]]> 175 </script> 176 <?php 177 do_action('admin_print_scripts'); 178 do_action('admin_head'); 179 if ( is_string($content_func) ) 180 do_action( "admin_head_{$content_func}" ); 181 ?> 182 </head> 183 <body> 184 <?php 185 $args = func_get_args(); 186 $args = array_slice($args, 1); 187 call_user_func_array($content_func, $args); 188 ?> 189 </body> 190 </html> 191 <?php 192 } 193 194 function media_buttons() { // just a placeholder for now 195 global $post_ID, $temp_ID; 196 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); 197 $uploading_iframe_src = wp_nonce_url("media-upload.php?type=image&&post_id=$uploading_iframe_ID", 'inlineuploading'); 198 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 199 $out = <<<EOF 200 <a href="{$uploading_iframe_src}&TB_iframe=true&height=500&width=460" class="thickbox"> 201 <img src="./images/media-buttons.gif" alt="" /> 202 </a> 203 EOF; 204 echo $out; 205 } 206 add_action( 'media_buttons', 'media_buttons' ); 207 208 function media_buttons_head() { 209 $siteurl = get_option('siteurl'); 210 echo "<style type='text/css' media='all'> 211 @import '{$siteurl}/wp-includes/js/thickbox/thickbox.css?1'; 212 div#TB_title { 213 background-color: #222222; 214 color: #cfcfcf; 215 } 216 div#TB_title a, div#TB_title a:visited { 217 color: #cfcfcf; 218 } 219 </style>\n"; 220 } 221 222 add_action( 'admin_print_scripts', 'media_buttons_head' ); 223 224 function media_admin_css() { 225 wp_admin_css('css/media'); 226 } 227 228 add_action('media_upload_image', 'image_upload_handler'); 229 add_action('admin_head_image_upload_form', 'media_admin_css'); 230 231 ?> 232 No newline at end of file -
wp-admin/includes/image.php
317 317 318 318 } 319 319 320 function media_buttons() { // just a placeholder for now321 ?>322 <img src="./images/media-buttons.gif" alt="" />323 <?php324 }325 add_action( 'media_buttons', 'media_buttons' );326 320 327 ?> 328 No newline at end of file 321 ?> -
wp-admin/includes/admin.php
4 4 require_once(ABSPATH . 'wp-admin/includes/comment.php'); 5 5 require_once(ABSPATH . 'wp-admin/includes/file.php'); 6 6 require_once(ABSPATH . 'wp-admin/includes/image.php'); 7 require_once(ABSPATH . 'wp-admin/includes/media.php'); 7 8 require_once(ABSPATH . 'wp-admin/includes/import.php'); 8 9 require_once(ABSPATH . 'wp-admin/includes/misc.php'); 9 10 require_once(ABSPATH . 'wp-admin/includes/plugin.php'); -
wp-admin/post.php
59 59 } 60 60 61 61 wp_enqueue_script('post'); 62 wp_enqueue_script('thickbox'); 63 wp_enqueue_script('media-upload'); 62 64 63 65 if ( 'draft' == $post->post_status ) 64 66 wp_enqueue_script('autosave'); -
wp-admin/js/media-upload.js
1 // send html to the post editor 2 function send_to_editor(h) { 3 var win = window.opener ? window.opener : window.dialogArguments; 4 if ( !win ) 5 win = top; 6 tinyMCE = win.tinyMCE; 7 if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) { 8 tinyMCE.selectedInstance.getWin().focus(); 9 tinyMCE.execCommand('mceInsertContent', false, h); 10 } else 11 win.edInsertContent(win.edCanvas, h); 12 } 13 No newline at end of file -
wp-admin/media-upload.php
1 <?php 2 require_once('admin.php'); 3 4 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 5 6 if (!current_user_can('upload_files')) 7 wp_die(__('You do not have permission to upload files.')); 8 9 // IDs should be integers 10 $ID = (int) $ID; 11 $post_id = (int) $post_id; 12 13 // Require an ID for the edit screen 14 if ( $action == 'edit' && !$ID ) 15 wp_die(__("You are not allowed to be here")); 16 17 // upload type: image, video, file, ..? 18 $type = @strval($_GET['type']); 19 20 // let the action code decide how to handle the request 21 do_action("media_upload_{$type}"); 22 23 ?> 24 No newline at end of file -
wp-admin/css/media.css
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-admin/images/align-right.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-admin/images/align-center.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-admin/images/align-left.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-admin/images/align-none.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream
1 div#media-upload-header { 2 background-color: #eaf3fa; 3 margin: none; 4 padding: 1em 0.5em 0.5em 0.5em; 5 font-weight: bold; 6 } 7 8 ul#media-upload-tabs { 9 display:inline; 10 position: absolute; 11 right: 1em; 12 top: 1em; 13 font-size: 0.9em; 14 } 15 16 ul#media-upload-tabs li { 17 display:inline; 18 } 19 20 ul#media-upload-tabs li:after { 21 content: " | "; 22 } 23 24 ul#media-upload-tabs li.last:after { 25 content: ""; 26 } 27 28 29 30 div#media-upload-error { 31 margin: 1em; 32 font-weight: bold; 33 color: #f00; 34 } 35 36 form.media-upload-form { 37 margin: 1em; 38 } 39 40 .media-upload-form label, .media-upload-form legend { 41 display:block; 42 font-weight: bold; 43 margin-bottom: 0.5em; 44 } 45 46 .media-upload-form label.form-help { 47 color: #9a9a9a; 48 font-style: italic; 49 font-weight: normal; 50 } 51 52 .media-upload-form p { 53 margin: 0 1em 1em 0; 54 } 55 56 .media-upload-form input[type="text"], .media-upload-form input[type="file"] { 57 width: 100%; 58 } 59 60 .media-upload-form fieldset { 61 border: none; 62 text-align: justify; 63 margin-bottom: 1em; 64 } 65 66 .media-upload-form button.button-ok { 67 float: right; 68 background-color: #ebebeb; 69 color: #1f4569; 70 border: none; 71 padding: 0.5em; 72 } 73 74 .media-upload-form a.button-cancel { 75 float: right; 76 background-color: #fff; 77 color: #9a9a9a; 78 font-size: 0.8em; 79 text-decoration: underline; 80 margin: 0.5em 1em; 81 } 82 83 /* specific to the image upload form */ 84 .media-upload-form fieldset#image-align label { 85 display: inline; 86 padding: 0 28px; 87 } 88 89 #image-align-none-label { 90 background: url(../images/align-none.png) no-repeat center left; 91 } 92 93 #image-align-left-label { 94 background: url(../images/align-left.png) no-repeat center left; 95 } 96 97 #image-align-center-label { 98 background: url(../images/align-center.png) no-repeat center left; 99 } 100 101 #image-align-right-label { 102 background: url(../images/align-right.png) no-repeat center left; 103 } 104 No newline at end of file