Php WordPress新图像大小显示不正确
我正在尝试添加一个新的图像大小,并在媒体模式中选择它 我已经检查了一个新的,正确大小的图像正在创建ie 670px宽 但模态窗口显示为604px宽,插入时,您会看到:Php WordPress新图像大小显示不正确,php,wordpress,Php,Wordpress,我正在尝试添加一个新的图像大小,并在媒体模式中选择它 我已经检查了一个新的,正确大小的图像正在创建ie 670px宽 但模态窗口显示为604px宽,插入时,您会看到: <img width="604" height="453" alt="two-new-honeys" src=".../two-new-honeys-670x503.jpg" class=".."> 这是一个特定于主题的变量$content\u width,为2013主题设置为604px,因此媒体模式覆盖了670px
<img width="604" height="453" alt="two-new-honeys" src=".../two-new-honeys-670x503.jpg" class="..">
这是一个特定于主题的变量$content\u width,为2013主题设置为604px,因此媒体模式覆盖了670px的我的图像,并将其缩小到$content\u width设置的大小 解决方案是在functions.php中重置$content\u width=xxx
<?php
//adjust $content_width only for chosen template
function custom_adjust_content_width() {
global $content_width;
if ( is_page_template( 'my-template.php' ) )
$content_width = 640;
}
add_action( 'template_redirect', 'custom_adjust_content_width' );
?>
请参见,以防有人需要它-有一种方法可以通过模板名称指定$content\u width。代码必须放在functions.php中
<?php
//adjust $content_width only for chosen template
function custom_adjust_content_width() {
global $content_width;
if ( is_page_template( 'my-template.php' ) )
$content_width = 640;
}
add_action( 'template_redirect', 'custom_adjust_content_width' );
?>