2012-03-25 97 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