Workaround for JetPack site accelerators causing full-size images to shrink when enabled
Sep 6, 2020
PHP
WordPress
Jetpack
Problem
When JetPack’s Site Accelerator </ q> and
Speed up static file loading </ q> are turned on in WordPress, the width of the image loaded in the post will be reduced.
Image size </ q>: Even if you specify
Full size </ q>, it will be reduced to 1024px.
Cause
JetPack refers to global $ content_width
to determine the maximum width of the image 1.
How to solve
Add the following contents to functions.php etc. and overwrite $ global $ content_width
2.
<? php
// ...
(function () {
global $ content_width;
$ content_width = 1920; // Specify the maximum expected width of the image.
}) ();
// ...
Remarks
In the future 3, it may be possible to change global $ content_width
withadd_theme_support ()
4.
Reference page
- Full image size (Gutenberg block “image”) is not full size but limited at 702px · Issue # 13433 · Automattic / jetpack.
- Content width-WordPress Codex Japanese version.
-
Therefore, if
global $ content_width
is specified in the theme, it may be a width other than 1024px. ↩︎ -
The specification in the child theme or plugin has not been verified. You may need to use
add_action ('after_setup_theme', $ function_to_add)
. ↩︎ -
The latest WordPress version at the time of this writing is 5.5.1. ↩︎
-
Cf. # 21256 (New theme feature –add_theme_support (‘content-width’, $ defaults)) – WordPress Trac. ↩︎