2012-03-25 95 views
0

该屏幕截图显示了问题:工具栏/内容高度。Wordpress tinymce编辑器高度错误

enter image description here

tinymcse相关的代码:

// wordpress plugin: 

add_filter('admin_head', array($this, 'editor_tiny_mce')); 
add_filter('tiny_mce_before_init', array($this, 'change_mce_options')); 

function editor_tiny_mce() 
{ 
    wp_enqueue_script('common'); 
    wp_enqueue_script('jquery-color'); 
    wp_print_scripts('editor'); 
    if (function_exists('add_thickbox')) 
    { 
     add_thickbox(); 
    } 
    wp_print_scripts('media-upload'); 
    if (function_exists('wp_tiny_mce')) 
    { 
     wp_tiny_mce(); 
    } 
    wp_admin_css(); 
    wp_enqueue_script('utils'); 
    do_action("admin_print_styles-post-php"); 
    do_action('admin_print_styles'); 
} 

function change_mce_options($init) 
{ 
    $init['height'] = '480px'; // this not works 
    return $init; 
} 

// html code 

<?php 
echo the_editor(stripslashes($pages_about_us_content), 'pages_about_us_content'); 
?> 

我试着用这个代码也解决它:

$("iframe[id$='_ifr']").height(500); // this not works 

,因为所有的TinyMCE的帧,_ifr但没有运气结束。这只有在编辑器只显示一个工具栏时才会出现。

欢迎任何建议。

+0

这可能有助于http://elklan.com/faqs/1553009/how-do-i-set-a-jquery-tooltip-from-a-database-on-server-side, – elclanrs 2012-03-25 21:45:54

+0

@elclanrs谢谢,但似乎不相关的! – 2012-03-25 21:53:27

回答

0

试试这个(刚加入此代码段functions.php文件里面只为编辑器工具栏大小)

add_filter('admin_head', 'editor_tiny_mce'); 
function editor_tiny_mce(){ 
?> 
    <style> 
    table td.mceToolbar{ 
     height:100px !important; 
    } 
    </style> 
<?php 
} 

enter image description here

的截图已经采取的200像素高度,你也可以尝试height:auto !important; 注意:也可以使用'wp_enqueue_style'函数使用此代码对css文件进行排队。

+1

我认为我发现了一个肮脏的解决方案,无论如何我正在构建一个插件。 Hack'functions.php'更加肮脏! THX :) – 2012-03-25 22:23:00

+0

对不起,我没有注意到这是一个插件。 – 2012-03-25 22:24:45

+0

嗯,我认为你可以使用一个css文件,如果你使用wp_enqueue_style添加css文件,那么它也可以解决,只是我的意见,如果你认为它没有解决方案时有帮助。谢谢。 – 2012-03-25 22:30:17