无法在 Wordpress 中更改大于 640px 的图像的显示大小?

Unable to change display size of images larger than 640px in Wordpress?

我在尝试更改媒体设置时遇到了问题。第一张图片是关于媒体设置以及 large/medium/thumbnail 图片有多大。我试着放大 960px。

第二张图是我在编辑页面尝试调整图片大小时看到的。但是我看不到960px选项。

我在媒体设置中尝试了一些小于 640px 的尺寸。有效。而如果对于一些大于 640px 的,比如 641px 和 960px,它只显示 640px。这么大好像达不到960px

那么,为什么我不能使用 960px?

我使用空白主题从头开始制作样式。到目前为止,我还没有更改任何图像设置功能。

大多数主题(尤其是来自 wordpress 的主题)对于插入 post 或页面的图像有特定的宽度限制(以像素为单位)。显然,该限制取决于主题的主列宽度(因主题而异)。

/wp-includes/media.php 有:

// we're inserting a full size image into the editor.  if it's a really big image we'll scale it down to fit reasonably
                // within the editor itself, and within the theme's content width if it's known.  the user can resize it in the editor
                // if they wish.
                if ( !empty($GLOBALS['content_width']) ) {
                        $max_width = $GLOBALS['content_width'];
                }
                else
                        <strong>$max_width = 500;</strong>

尝试在主题 function.php

中用 $GLOBALS['content_width'] = 960; 覆盖

正如@Debajyoti Das 所解释的那样,大多数主题都有固定的内容宽度。

要么在您的主题中找到宽度并进行修改(在文件中搜索 640),要么如果您有子主题,则在您的 functions.php 中添加以下代码,这通常会覆盖主题宽度设置。

例如,这适用于 Understrap 框架:

// set theme width
global $content_width;
$content_width = 1024;