diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 2b6aa14f81..19edd9eed7 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -39,12 +39,14 @@ function convertEntities(o) { return s; } - if ( typeof o === 'object' ) { - for (var v in o) - o[v] = c(o[v]); - return o; - } else if ( typeof o === 'string' ) + if ( typeof o === 'string' ) return c(o); + else if ( typeof o === 'object' ) + for (var v in o) { + if ( typeof o[v] === 'string' ) + o[v] = c(o[v]); + } + return o; }; //]]> diff --git a/wp-admin/css/colors-classic.css b/wp-admin/css/colors-classic.css index 03bb7b8ec9..348d5eb193 100644 --- a/wp-admin/css/colors-classic.css +++ b/wp-admin/css/colors-classic.css @@ -1449,12 +1449,18 @@ form p.submit a.cancel:hover { border-color: #999; } -#wp_editimgbtn, #wp_delimgbtn { +#wp_editimgbtn, +#wp_delimgbtn, +#wp_editgallery, +#wp_delgallery { border-color: #999; background-color: #eee; } -#wp_editimgbtn:hover, #wp_delimgbtn:hover { +#wp_editimgbtn:hover, +#wp_delimgbtn:hover, +#wp_editgallery:hover, +#wp_delgallery:hover { border-color: #555; background-color: #ccc; } diff --git a/wp-admin/css/colors-fresh.css b/wp-admin/css/colors-fresh.css index 6a66b3578c..9b2a0036dc 100644 --- a/wp-admin/css/colors-fresh.css +++ b/wp-admin/css/colors-fresh.css @@ -1452,12 +1452,18 @@ form p.submit a.cancel:hover { border-color: #999; } -#wp_editimgbtn, #wp_delimgbtn { +#wp_editimgbtn, +#wp_delimgbtn, +#wp_editgallery, +#wp_delgallery { border-color: #999; background-color: #eee; } -#wp_editimgbtn:hover, #wp_delimgbtn:hover { +#wp_editimgbtn:hover, +#wp_delimgbtn:hover, +#wp_editgallery:hover, +#wp_delgallery:hover { border-color: #555; background-color: #ccc; } diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index e6cb15c072..7fb118f636 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1124,7 +1124,7 @@ function wp_tiny_mce( $teeny = false ) { $plugins = apply_filters( 'teeny_mce_plugins', array('safari', 'inlinepopups', 'media', 'autosave', 'fullscreen') ); $ext_plugins = ''; } else { - $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage' ); + $plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery' ); /* The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'. diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 8a8b8ed397..0a4140695e 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -2183,14 +2183,18 @@ fieldset { font: 18px "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; } -#wp_editbtns { +#wp_editbtns, +#wp_gallerybtns { padding: 2px; position: absolute; display: none; z-index: 999998; } -#wp_editimgbtn, #wp_delimgbtn { +#wp_editimgbtn, +#wp_delimgbtn, +#wp_editgallery, +#wp_delgallery { margin: 2px; padding: 2px; border-width: 1px; diff --git a/wp-includes/js/tinymce/langs/wp-langs-en.js b/wp-includes/js/tinymce/langs/wp-langs-en.js index 4c8ab54e0e..d584c9aacb 100644 --- a/wp-includes/js/tinymce/langs/wp-langs-en.js +++ b/wp-includes/js/tinymce/langs/wp-langs-en.js @@ -427,3 +427,29 @@ img_title:"Edit Image Title", caption:"Edit Image Caption", alt:"Edit Alternate Text" }); + +tinyMCE.addI18n("en.gallery",{ +settings:"Gallery Settings", +linkto:"Link thumbnails to:", +linktofile:"Image File", +linktopost:"Attachment Page", +orderby:"Order images by:", +menu_order:"Menu order", +byname:"Name", +bydate:"Date/Time", +random:"Random", +order:"Order:", +orderasc:"Ascending", +orderdesc:"Descending", +cols:"Gallery columns:", +two:"two", +three:"three", +four:"four", +five:"five", +six:"six", +seven:"seven", +eight:"eight", +nine:"nine", +imgwidth:"Limit the thumbnails width:", +imgwidthhelp:"Overrides the thumbnail images width. The default can be changed from the Media Settings page." +}); diff --git a/wp-includes/js/tinymce/langs/wp-langs.php b/wp-includes/js/tinymce/langs/wp-langs.php index d7cc8f4ac2..6dc547fa1f 100644 --- a/wp-includes/js/tinymce/langs/wp-langs.php +++ b/wp-includes/js/tinymce/langs/wp-langs.php @@ -450,6 +450,30 @@ img_title:"' . mce_escape( __('Edit Image Title') ) . '", caption:"' . mce_escape( __('Edit Image Caption') ) . '", alt:"' . mce_escape( __('Edit Alternate Text') ) . '" }); -'; -// mce_put_file( ABSPATH . WPINC . '/js/tinymce/langs/wp-langs-' . $language . '.js', $lang ); +tinyMCE.addI18n("' . $language . '.gallery",{ +settings:"' . mce_escape( __('Gallery Settings') ) . '", +linkto:"' . mce_escape( __('Link thumbnails to:') ) . '", +linktofile:"' . mce_escape( __('Image File') ) . '", +linktopost:"' . mce_escape( __('Attachment Page') ) . '", +orderby:"' . mce_escape( __('Order images by:') ) . '", +menu_order:"' . mce_escape( __('Menu order') ) . '", +byname:"' . mce_escape( __('Name') ) . '", +bydate:"' . mce_escape( __('Date/Time') ) . '", +random:"' . mce_escape( __('Random') ) . '", +order:"' . mce_escape( __('Order:') ) . '", +orderasc:"' . mce_escape( __('Ascending') ) . '", +orderdesc:"' . mce_escape( __('Descending') ) . '", +cols:"' . mce_escape( __('Gallery columns:') ) . '", +two:"' . mce_escape( __('two') ) . '", +three:"' . mce_escape( __('three') ) . '", +four:"' . mce_escape( __('four') ) . '", +five:"' . mce_escape( __('five') ) . '", +six:"' . mce_escape( __('six') ) . '", +seven:"' . mce_escape( __('seven') ) . '", +eight:"' . mce_escape( __('eight') ) . '", +nine:"' . mce_escape( __('nine') ) . '", +imgwidth:"' . mce_escape( __('Limit the thumbnails width:') ) . '", +imgwidthhelp:"' . mce_escape( __('Overrides the thumbnail images width. The default can be changed from the Media Settings page.') ) . '" +}); +'; diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css b/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css index c6789d5370..26974d3400 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css +++ b/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css @@ -88,7 +88,7 @@ th.label { overflow: hidden; } -#media-upload #img-edit { +#img-edit { border: 1px solid #dfdfdf; width: 623px; margin: 15px auto; @@ -100,11 +100,10 @@ th.label { } #img_demo_txt { - font-size: 6px; - line-height: 10px; - font-family: "Courier New",Courier,monotype; - color: #ccc; - background-color: #ccc; + font-size: 9px; + line-height: 13px; + font-family: Monaco,"Courier New",Courier,monospace; + color: #888; } #img_demo { @@ -132,6 +131,7 @@ th.label { border-top-width: 1px; display: block; float: left; + height: 28px; line-height: 28px; text-decoration: none; text-align: center; @@ -332,3 +332,12 @@ div#media-upload-error { margin: 1em; font-weight: bold; } + +* html #sidemenu li { + zoom: 100%; +} + +* html #sidemenu a { + height: 27px; + line-height: 26px; +} diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js index 7c5c00ba75..f24d0bafae 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.js @@ -11,8 +11,9 @@ // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'); ed.addCommand('WP_EditImage', function() { var el = ed.selection.getNode(), vp = tinymce.DOM.getViewPort(), H = vp.h, W = ( 720 < vp.w ) ? 720 : vp.w; + var cls = ed.dom.getAttrib(el, 'class'); - if ( ed.dom.getAttrib(el, 'class').indexOf('mceItem') != -1 || el.nodeName != 'IMG' ) + if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' ) return; tb_show('', url + '/editimage.html?ver=321&TB_iframe=true'); @@ -142,8 +143,9 @@ showButtons : function(n) { var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y; + var cls = ed.dom.getAttrib(n, 'class'); - if (ed.dom.getAttrib(n, 'class').indexOf('mceItem') != -1) + if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 ) return; vp = ed.dom.getViewPort(ed.getWin()); diff --git a/wp-includes/js/tinymce/plugins/wpgallery/css/gallery.css b/wp-includes/js/tinymce/plugins/wpgallery/css/gallery.css new file mode 100644 index 0000000000..dedb297a82 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpgallery/css/gallery.css @@ -0,0 +1,208 @@ + +html, body { + background-color: #f9f9f9; + margin: 0; + padding: 0; +} + +.button, +.button-primary, +.button-secondary { + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; + text-decoration: none; + font-size: 11px !important; + line-height: 16px; + padding: 2px 8px; + cursor: pointer; + border-width: 1px; + border-style: solid; + -moz-border-radius: 11px; + -khtml-border-radius: 11px; + -webkit-border-radius: 11px; + border-radius: 11px; + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; + -khtml-box-sizing: content-box; + box-sizing: content-box; +} + +a.button { + padding: 4px 8px; +} + +textarea, +input, +select { + font: 13px Verdana, Arial, Helvetica, sans-serif; + margin: 1px; + padding: 2px; + background-color: #fff; +} + +.align input { + vertical-align: middle; +} + +body, td { + font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif; +} + +.alignright { + float: right; +} + +.alignleft { + float: left; +} + +.aligncenter { + display: block; + margin-left: auto; + margin-right: auto; +} + +label { + cursor: pointer; +} + +th.label { + width: 160px; +} + +#media-upload #basic th.label { + padding: 5px 5px 5px 0; +} + +#media-upload #basic .imgwidth { + vertical-align: top; +} + +#saveeditimg { + padding: 10px 0 0 5px; +} + +#sidemenu, +#sidemenu li { + list-style: none; +} + +#sidemenu li { + display: inline; +} + +#sidemenu a { + border-bottom-style: solid; + border-bottom-width: 1px; + border-top-style: solid; + border-top-width: 1px; + display: block; + float: left; + line-height: 28px; + text-decoration: none; + text-align: center; + white-space: nowrap; + margin: 0; + padding: 0pt 7px; +} + +#sidemenu a.current { + -moz-border-radius-topleft: 4px; + -khtml-border-top-left-radius: 4px; + -webkit-border-top-left-radius: 4px; + border-top-left-radius: 4px; + -moz-border-radius-topright: 4px; + -khtml-border-top-right-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-right-radius: 4px; + border-style:solid; + border-width:1px; + font-weight:normal; +} + +#media-upload h3 { + clear: both; + padding: 0pt 0pt 3px; + border-bottom-style: solid; + border-bottom-width: 1px; + font-family: Georgia,"Times New Roman",Times,serif; + font-size: 20px; + font-weight: normal; + line-height: normal; + margin: 0 0 10px -4px; + padding: 15px 0 3px; + border-bottom-color: #DADADA; + color: #5A5A5A; +} + +#basic { + padding-top: 2px; +} + +td { + padding: 2px 0; +} + +.describe td { + vertical-align: middle; + height: 3.5em; +} + +#media-upload .describe th.label { + padding-top: .5em; + text-align: left; +} + +#media-upload .describe { + border: 1px solid #dfdfdf; + padding: 5px 15px; + width: 100%; + clear: both; + cursor: default; +} + +form { + margin: 1em; +} + +.describe select { + width: 15em; + border: 1px solid #dfdfdf; +} + +#imgwidth { + width: 3em; + border: 1px solid #dfdfdf; +} + +.media-upload-form label, +.media-upload-form legend { + font-size: 13px; + color: #464646; +} + +.align .field label { + margin: 0 1.5em 0 0; +} + +div#media-upload-header { + margin: 0; + padding: 0 5px; + font-weight: bold; + position: relative; + border-bottom-width: 1px; + border-bottom-style: solid; + height: 2.5em; +} + +body#media-upload ul#sidemenu { + font-weight: normal; + margin: 0 5px; + position: relative; + left: 0px; + bottom: -4px; +} + +div#media-upload-error { + margin: 1em; + font-weight: bold; +} diff --git a/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js b/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js new file mode 100644 index 0000000000..e5aaf7c5fb --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin.js @@ -0,0 +1,189 @@ + +(function() { + tinymce.create('tinymce.plugins.wpGallery', { + + init : function(ed, url) { + var t = this; + + t.url = url; + t._createButtons(); + + // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'); + ed.addCommand('WP_Gallery', function() { + var el = ed.selection.getNode(), vp = tinymce.DOM.getViewPort(), W = ( 720 < vp.w ) ? 720 : vp.w; + + if ( el.nodeName != 'IMG' ) return; + if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) return; + + tb_show('', url + '/gallery.html?ver=321&TB_iframe=true'); + tinymce.DOM.setStyles('TB_window', { + 'width':( W - 50 )+'px', + 'height':'430px', + 'margin-left':'-'+parseInt((( W - 50 ) / 2),10) + 'px' + }); + + if ( ! tinymce.isIE6 ) { + tinymce.DOM.setStyles('TB_window', { + 'top':'30px', + 'marginTop':'0' + }); + } + + tinymce.DOM.setStyles('TB_iframeContent', { + 'width':( W - 50 )+'px', + 'height':'400px' + }); + tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' ); + }); + + ed.onInit.add(function(ed) { + tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) { + ed.plugins.wpgallery.hideButtons(); + }); + }); + + ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) { + ed.plugins.wpgallery.hideButtons(); + }); + + ed.onSaveContent.add(function(ed, o) { + ed.plugins.wpgallery.hideButtons(); + }); + + ed.onMouseUp.add(function(ed, e) { + if ( tinymce.isOpera ) { + if ( e.target.nodeName == 'IMG' ) + ed.plugins.wpgallery.showButtons(e.target); + } + + }); + + ed.onMouseDown.add(function(ed, e) { + if ( tinymce.isOpera || e.target.nodeName != 'IMG' ) { + t.hideButtons(); + return; + } + ed.plugins.wpgallery.showButtons(e.target); + }); + + ed.onBeforeSetContent.add(function(ed, o) { + o.content = t._do_gallery(o.content); + }); + + ed.onPostProcess.add(function(ed, o) { + if (o.get) + o.content = t._get_gallery(o.content); + }); + }, + + _do_gallery : function(co) { + return co.replace(/\[gallery([^\]]*)\]/g, function(a){ + return ''; + }); + }, + + _get_gallery : function(co) { + + function getAttr(s, n) { + n = new RegExp(n + '=\"([^\"]+)\"', 'g').exec(s); + return n ? tinymce.DOM.decode(n[1]) : ''; + }; + + return co.replace(/(?:]*>)*(]+>)(?:<\/p>)*/g, function(a,im) { + var cls = getAttr(im, 'class'); + + if ( cls.indexOf('wpGallery') != -1 ) + return '

'+getAttr(im, 'title')+'

'; + + return im; + }); + }, + + showButtons : function(n) { + var t = this, ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y; + + if (ed.dom.getAttrib(n, 'class').indexOf('wpGallery') == -1) + return; + + vp = ed.dom.getViewPort(ed.getWin()); + p1 = DOM.getPos(ed.getContentAreaContainer()); + p2 = ed.dom.getPos(n); + + X = Math.max(p2.x - vp.x, 0) + p1.x; + Y = Math.max(p2.y - vp.y, 0) + p1.y; + + DOM.setStyles('wp_gallerybtns', { + 'top' : Y+5+'px', + 'left' : X+5+'px', + 'display' : 'block' + }); + + t.btnsTout = window.setTimeout( function(){ed.plugins.wpgallery.hideButtons();}, 5000 ); + }, + + hideButtons : function() { + if ( tinymce.DOM.isHidden('wp_gallerybtns') ) return; + + tinymce.DOM.hide('wp_gallerybtns'); + window.clearTimeout(this.btnsTout); + }, + + _createButtons : function() { + var t = this, ed = tinyMCE.activeEditor, DOM = tinymce.DOM; + + DOM.remove('wp_gallerybtns'); + + var wp_gallerybtns = DOM.add(document.body, 'div', { + id : 'wp_gallerybtns', + style : 'display:none;' + }); + + var wp_editgallery = DOM.add('wp_gallerybtns', 'img', { + src : t.url+'/img/edit.png', + id : 'wp_editgallery', + width : '24', + height : '24', + title : ed.getLang('wpgallery.edit') + }); + + wp_editgallery.onmousedown = function(e) { + var ed = tinyMCE.activeEditor; + ed.windowManager.bookmark = ed.selection.getBookmark('simple'); + ed.execCommand("WP_Gallery"); + this.parentNode.style.display = 'none'; + }; + + var wp_delgallery = DOM.add('wp_gallerybtns', 'img', { + src : t.url+'/img/delete.png', + id : 'wp_delgallery', + width : '24', + height : '24', + title : ed.getLang('wpgallery.del') + }); + + wp_delgallery.onmousedown = function(e) { + var ed = tinyMCE.activeEditor, el = ed.selection.getNode(); + + if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('mceItemWPgallery') != -1 ) { + ed.dom.remove(el); + + this.parentNode.style.display = 'none'; + ed.execCommand('mceRepaint'); + return false; + } + }; + }, + + getInfo : function() { + return { + longname : 'Gallery Settings', + author : 'WordPress', + authorurl : 'http://wordpress.org', + infourl : '', + version : "1.0" + }; + } + }); + + tinymce.PluginManager.add('wpgallery', tinymce.plugins.wpGallery); +})(); diff --git a/wp-includes/js/tinymce/plugins/wpgallery/gallery.html b/wp-includes/js/tinymce/plugins/wpgallery/gallery.html new file mode 100644 index 0000000000..0a94195df7 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpgallery/gallery.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ + + +
+ + + + + + + +
+ + + +
+ + + +

{#gallery.imgwidthhelp}

+
+ +
+ + +
+
+
+
+ + + diff --git a/wp-includes/js/tinymce/plugins/wpgallery/img/delete.png b/wp-includes/js/tinymce/plugins/wpgallery/img/delete.png new file mode 100644 index 0000000000..d64d8a66eb Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wpgallery/img/delete.png differ diff --git a/wp-includes/js/tinymce/plugins/wpgallery/img/edit.png b/wp-includes/js/tinymce/plugins/wpgallery/img/edit.png new file mode 100644 index 0000000000..41def5115e Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wpgallery/img/edit.png differ diff --git a/wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png b/wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png new file mode 100644 index 0000000000..f55428bc47 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wpgallery/img/gallery.png differ diff --git a/wp-includes/js/tinymce/plugins/wpgallery/img/t.gif b/wp-includes/js/tinymce/plugins/wpgallery/img/t.gif new file mode 100644 index 0000000000..388486517f Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wpgallery/img/t.gif differ diff --git a/wp-includes/js/tinymce/plugins/wpgallery/js/gallery.js b/wp-includes/js/tinymce/plugins/wpgallery/js/gallery.js new file mode 100644 index 0000000000..0b8daf480b --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wpgallery/js/gallery.js @@ -0,0 +1,165 @@ + +var tinymce = null, tinyMCEPopup, tinyMCE; + +tinyMCEPopup = { + init: function() { + var t = this, w, ti, li, q, i, it; + + li = ('' + document.location.search).replace(/^\?/, '').split('&'); + q = {}; + for (i=0; i' ); + } + }, + + I : function(e) { + return document.getElementById(e); + }, + + init : function() { + var ed = tinyMCEPopup.editor, h; + + h = document.body.innerHTML; + + // Replace a=x with a="x" in IE + if (tinymce.isIE) + h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"') + + document.body.innerHTML = ed.translate(h); + window.setTimeout( function(){wpgallery.setup();}, 100 ); + }, + + setup : function() { + var t = this, a, f = document.forms[0], ed = tinyMCEPopup.editor, dom = tinyMCEPopup.dom; + document.dir = tinyMCEPopup.editor.getParam('directionality',''); + + tinyMCEPopup.restoreSelection(); + el = ed.selection.getNode(); + if (el.nodeName != 'IMG') return; + + a = ed.dom.getAttrib(el, 'title'); + a = ed.dom.decode(a); + + if ( a ) { + var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i); + var imgwidth = a.match(/imgwidth=['"]([0-9]+)['"]/), order = a.match(/order=['"]([^'"]+)['"]/i); + var orderby = a.match(/orderby=['"]([^'"]+)['"]/i), all = ''; + + if ( link && link[1] ) t.I('linkto-file').checked = "checked"; + if ( order && order[1] ) t.I('order-desc').checked = "checked"; + if ( columns && columns[1] ) t.I('columns').value = ''+columns[1]; + if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1]; + if ( imgwidth && imgwidth[1] ) t.I('imgwidth').value = imgwidth[1]; + } + + document.body.style.display = ''; + }, + + update : function() { + var t = this, ed = tinyMCEPopup.editor, el, all; + + tinyMCEPopup.restoreSelection(); + el = ed.selection.getNode(); + + if (el.nodeName != 'IMG') return; + + all = ed.dom.decode(ed.dom.getAttrib(el, 'title')); + all = all.substr(0, all.lastIndexOf(']')); + all = all.replace(/\s*(order|link|columns|orderby|imgwidth)=['"]([^'"]+)['"]/gi, ''); + + if ( t.I('linkto-file').checked ) + all += ' link="file"'; + + if ( t.I('order-desc').checked ) + all += ' order="DESC"'; + + if ( t.I('columns').value != 3 ) + all += ' columns="'+t.I('columns').value+'"'; + + if ( t.I('orderby').value != 'menu_order' ) + all += ' orderby="'+t.I('orderby').value+'"'; + + if ( t.I('imgwidth').value ) + all += ' imgwidth="'+t.I('imgwidth').value+'"'; + + all += ']'; + + ed.dom.setAttrib(el, 'title', all); + tinyMCEPopup.close(); + } +}; + +window.onload = function(){wpgallery.init();} +wpgallery.preInit(); diff --git a/wp-includes/js/tinymce/wordpress.css b/wp-includes/js/tinymce/wordpress.css index 0bc5f5521f..eaf9a58cc1 100644 --- a/wp-includes/js/tinymce/wordpress.css +++ b/wp-includes/js/tinymce/wordpress.css @@ -40,6 +40,13 @@ dl.aligncenter { margin: 0; } +img.wpGallery { + border: 1px dotted #cc0000; + background: #ffffcc url("plugins/wpgallery/img/gallery.png") no-repeat scroll center center; + width: 99%; + height: 250px; +} + body.mceContentBody { background: #fff; color: #000; diff --git a/wp-includes/media.php b/wp-includes/media.php index 0c33ec64c6..d0dab99f67 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -522,15 +522,16 @@ function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = * @param int $attachment_id Image attachment ID. * @param string $size Optional, default is 'thumbnail'. * @param bool $icon Optional, default is false. Whether it is an icon. + * @param int $imgwidth Override image width. * @return string HTML img element or empty string on failure. */ -function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false) { +function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $imgwidth = false) { $html = ''; $image = wp_get_attachment_image_src($attachment_id, $size, $icon); if ( $image ) { list($src, $width, $height) = $image; - $hwstring = image_hwstring($width, $height); + $hwstring = $imgwidth ? image_hwstring($imgwidth, '') : image_hwstring($width, $height); if ( is_array($size) ) $size = join('x', $size); $html = ''; @@ -618,6 +619,7 @@ function gallery_shortcode($attr) { 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', + 'imgwidth' => '' ), $attr)); $id = intval($id); @@ -637,6 +639,7 @@ function gallery_shortcode($attr) { $captiontag = tag_escape($captiontag); $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; + $imgwidth = isset($imgwidth) && (int) $imgwidth ? $imgwidth : false; $output = apply_filters('gallery_style', "