Gallery settings for TinyMCE

git-svn-id: http://svn.automattic.com/wordpress/trunk@9847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-11-23 06:37:15 +00:00
parent f92c019881
commit 3c15f6a8d3
21 changed files with 801 additions and 28 deletions

View File

@ -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;
};
//]]>
</script>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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'.

View File

@ -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;

View File

@ -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."
});

View File

@ -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.') ) . '"
});
';

View File

@ -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;
}

View File

@ -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());

View File

@ -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;
}

View File

@ -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 '<img src="'+tinymce.baseURL+'/plugins/wpgallery/img/t.gif" class="wpGallery" title="'+tinymce.DOM.encode(a)+'" />';
});
},
_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[^>]*>)*(<img[^>]+>)(?:<\/p>)*/g, function(a,im) {
var cls = getAttr(im, 'class');
if ( cls.indexOf('wpGallery') != -1 )
return '<p>'+getAttr(im, 'title')+'</p>';
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);
})();

View File

@ -0,0 +1,121 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<script type="text/javascript" src="js/gallery.js?ver=321"></script>
<script type="text/javascript" src="../../utils/form_utils.js?ver=321"></script>
<link rel="stylesheet" href="css/gallery.css?ver=321" type="text/css" media="all" />
<script type="text/javascript">
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
document.write('<link rel="stylesheet" href="css/gallery-rtl.css?ver=321" type="text/css" media="all" />');
</script>
<base target="_self" />
</head>
<body id="media-upload" style="display:none;">
<div id="media-upload-header">
<ul id="sidemenu">
<li><a href="javascript:;" id="tab_basic" class="current">{#gallery.settings}</a></li>
</ul>
</div>
<div id="img-edit">
<form class="media-upload-form" action="" onsubmit="wpgallery.update();">
<div id="div_basic">
<table id="basic" class="describe">
<tbody>
<tr class="align">
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.linkto}</span>
</label>
</th>
<td class="field">
<input type="radio" name="linkto" id="linkto-file" value="file" />
<label for="linkto-file" class="radio">{#gallery.linktofile}</label>
<input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
<label for="linkto-post" class="radio">{#gallery.linktopost}</label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.orderby}</span>
</label>
</th>
<td class="field">
<select id="orderby" name="orderby">
<option value="menu_order" selected="selected">{#gallery.menu_order}</option>
<option value="post_name">{#gallery.byname}</option>
<option value="ID">{#gallery.bydate}</option>
<option value="RAND()">{#gallery.random}</option>
</select>
</td>
</tr>
<tr class="align">
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.order}</span>
</label>
</th>
<td class="field">
<input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
<label for="order-asc" class="radio">{#gallery.orderasc}</label>
<input type="radio" name="order" id="order-desc" value="desc" />
<label for="order-desc" class="radio">{#gallery.orderdesc}</label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.cols}</span>
</label>
</th>
<td class="field">
<select id="columns" name="columns">
<option value="2">{#gallery.two}</option>
<option value="3" selected="selected">{#gallery.three}</option>
<option value="4">{#gallery.four}</option>
<option value="5">{#gallery.five}</option>
<option value="6">{#gallery.six}</option>
<option value="7">{#gallery.seven}</option>
<option value="8">{#gallery.eight}</option>
<option value="9">{#gallery.nine}</option>
</select>
</td>
</tr>
<tr>
<th scope="row" class="label imgwidth">
<label>
<span class="alignleft">{#gallery.imgwidth}</span>
</label>
</th>
<td class="field">
<input type="text" id="imgwidth" name="imgwidth" value="" size="6" />
<p>{#gallery.imgwidthhelp}</p>
</td>
</tr>
</tbody>
</table></div>
<div id="saveeditimg">
<input type="button" class="button alignleft" id="cancelimg" name="cancelimg" value="{#cancel}" onclick="tinyMCEPopup.close();" />
<input type="submit" id="saveimg" class="button-primary alignright" value="{#update}" />
<div style="clear:both"></div>
</div>
</form>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

View File

@ -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<li.length; i++) {
it = li[i].split('=');
q[unescape(it[0])] = unescape(it[1]);
}
if (q.mce_rdomain)
document.domain = q.mce_rdomain;
// Find window & API
w = t.getWin();
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.params = t.editor.windowManager.params;
// Setup local DOM
t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
},
getWin : function() {
return window.dialogArguments || opener || parent || top;
},
getParam : function(n, dv) {
return this.editor.getParam(n, dv);
},
close : function() {
var t = this, win = t.getWin();
// To avoid domain relaxing issue in Opera
function close() {
win.tb_remove();
tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup
};
if (tinymce.isOpera)
win.setTimeout(close, 0);
else
close();
},
execCommand : function(cmd, ui, val, a) {
a = a || {};
a.skip_focus = 1;
this.restoreSelection();
return this.editor.execCommand(cmd, ui, val, a);
},
storeSelection : function() {
this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
},
restoreSelection : function() {
var t = tinyMCEPopup;
if (tinymce.isIE)
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
}
}
tinyMCEPopup.init();
var wpgallery = {
preInit : function() {
// import colors stylesheet from parent
var win = tinyMCEPopup.getWin();
var styles = win.document.styleSheets;
for ( i = 0; i < styles.length; i++ ) {
var url = styles.item(i).href;
if ( url && url.indexOf('colors') != -1 )
document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );
}
},
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();

View File

@ -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;

View File

@ -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 = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" alt="" />';
@ -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', "
<style type='text/css'>
@ -660,7 +663,8 @@ function gallery_shortcode($attr) {
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$link = wp_get_attachment_link($id, $size, true);
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false, $imgwidth) : wp_get_attachment_link($id, $size, true, false, $imgwidth);
$output .= "<{$itemtag} class='gallery-item'>";
$output .= "
<{$icontag} class='gallery-icon'>

View File

@ -757,7 +757,7 @@ function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $p
* @param bool $icon Optional, default is false. Whether to include icon.
* @return string HTML content.
*/
function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $imgwidth = false) {
$id = intval($id);
$_post = & get_post( $id );
@ -769,7 +769,7 @@ function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false
$post_title = attribute_escape($_post->post_title);
$link_text = wp_get_attachment_image($id, $size, $icon);
$link_text = wp_get_attachment_image($id, $size, $icon, $imgwidth);
if ( !$link_text )
$link_text = $_post->post_title;

View File

@ -61,7 +61,7 @@ function wp_default_scripts( &$scripts ) {
// Modify this version when tinyMCE plugins are changed.
function mce_version() {
return '20081116';
return '20081122';
}
add_filter( 'tiny_mce_version', 'mce_version' );