Insert image fixes from azaozz. fixes #7177

git-svn-id: http://svn.automattic.com/wordpress/trunk@8189 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-06-24 21:59:06 +00:00
parent bf9f2f1cc7
commit cdaefc84b8
3 changed files with 20 additions and 11 deletions

View File

@ -65,10 +65,10 @@ function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = fal
function media_send_to_editor($html) {
?>
<script type="text/javascript">
<!--
top.send_to_editor('<?php echo addslashes($html); ?>');
top.tb_remove();
-->
/* <![CDATA[ */
var win = window.dialogArguments || opener || parent || top;
win.send_to_editor('<?php echo addslashes($html); ?>');
/* ]]> */
</script>
<?php
exit;

View File

@ -1,13 +1,15 @@
// send html to the post editor
function send_to_editor(h) {
var win = window.dialogArguments || opener || parent || top;
if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) {
ed.focus();
if (tinymce.isIE)
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
tinyMCE = win.tinyMCE;
if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.getInstanceById('content') ) && !ed.isHidden() ) {
tinyMCE.selectedInstance.getWin().focus();
tinyMCE.execCommand('mceInsertContent', false, h);
ed.execCommand('mceInsertContent', false, h);
} else
win.edInsertContent(win.edCanvas, h);
edInsertContent(edCanvas, h);
tb_remove();
}
// thickbox settings
@ -35,6 +37,13 @@ jQuery(function($) {
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
});
};
jQuery('a.thickbox').click(function(){
if ( typeof tinyMCE != 'undefined' && tinyMCE.activeEditor ) {
tinyMCE.get('content').focus();
tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark('simple');
}
});
$(window).resize( function() { tb_position() } );
});

View File

@ -159,7 +159,7 @@ function wp_default_scripts( &$scripts ) {
'edit' => __('Edit'),
) );
$scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080520' );
$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080523' );
$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20080624' );
$scripts->localize( 'upload', 'uploadL10n', array(
'browseTitle' => attribute_escape(__('Browse your files')),
'back' => __('&laquo; Back'),