問題
WordPress で JetPack の サイトアクセラレーターを有効化
と静的ファイルの読み込みをスピードアップ
を ON にしていると、投稿内で読み込まれる画像の幅が、画像サイズ
: フルサイズ
を指定していても、1024px に縮小されたものになってしまいます。
原因
JetPack は global $content_width
を参照して、画像の最大幅を決定しているため1。
解消方法
functions.php 等に以下の内容を追記し $global $content_width
を上書きします2。
functions.php
<?php
// ...
( function() {
global $content_width;
$content_width = 1920; // 想定される画像の最大幅を指定する.
} )();
// ...
備考
将来的3に、add_theme_support()
で global $content_width
を変更できるようになる可能性があります4。
参考ページ
- Full image size (Gutenberg block "image") is not full size but limited at 702px · Issue #13433 · Automattic/jetpack.
- コンテンツ幅 - WordPress Codex 日本語版.
-
したがって、テーマ内で
global $content_width
が指定されている場合は、1024px 以外の幅になる場合もあります。 ↩ -
子テーマやプラグイン内での指定は未検証です。
add_action( 'after_setup_theme', $function_to_add )
を使う必要があるかもしれません。 ↩ -
この記事の執筆時点での最新 WordPress バージョンは、5.5.1。 ↩
-
Cf. #21256 (New theme feature - add_theme_support( 'content-width', $defaults )) – WordPress Trac. ↩