問題描述
在更新到 WordPress 3.5 之後,我的自動嵌入限制為 500px 的寬度,並且此尺寸的設定已使用 WordPress 3.5 刪除
另外,我找不到 wp_options 表中的值。
有誰知道如何改變他們?
乾杯,fischi
最佳解決方案
請參閱 wp-includes/media.php 中的 wp_embed_defaults()功能:
function wp_embed_defaults() {
if ( ! empty( $GLOBALS['content_width'] ) )
$width = (int) $GLOBALS['content_width'];
if ( empty( $width ) )
$width = 500;
$height = min( ceil( $width * 1.5 ), 1000 );
return apply_filters( 'embed_defaults', compact( 'width', 'height' ) );
}
要更改這些值過濾器 embed_defaults:
add_filter( 'embed_defaults', 'wpse_76102_new_embed_size' );
function wpse_76102_new_embed_size()
{
// adjust these pixel values to your needs
return array( 'width' => 1000, 'height' => 600 );
}
次佳解決方案
這對我來說是從 http://www.wpbeginner.com/wp-themes/how-to-set-oembed-max-width-in-wordpress-3-5-with-content_width/工作的
將以下內容新增到 functions.php
if ( ! isset( $content_width ) ) $content_width = 600;
然後不得不進去,re-save 的職位,使其工作。
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。