Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
53 views
in Technique[技术] by (71.8m points)

php - WordPress add_image_size Not Generating Widths Between 1600px and 2300px

I am trying to generate images from 3840w on down, using whatever larger starting width image is uploaded. The WordPress documentation is pretty straightforward, yet I have tried every combination and nothing works, including using a plugin. I scoured the web and nobody seems to have had this type of problem of it skipping a few sizes even though I am trying it on the latest bare base WPEngine WordPress setup.

Basically, the code will not generate images between around 1600w and 2300w, which is an issue when I need 1920w (1080p) images. I used the following code:

add_filter( 'big_image_size_threshold', function(){ return false; } );

// adds image size for full 1080p (1920x1200)
add_action( 'after_setup_theme', 'wpdocs_theme_setup' );
function wpdocs_theme_setup() {
    add_image_size( '4k', 3840, 0, false );
    add_image_size( 'test12', 2600, 0, false );
    add_image_size( 'test11', 2500, 0, false );
    add_image_size( 'test0', 2400, 0, false );
    add_image_size( 'test9', 2300, 0, false );
    add_image_size( 'test8', 2200, 0, false );
    add_image_size( 'test7', 2100, 0, false );
    add_image_size( 'test6', 2000, 0, false );
    add_image_size( 'test5', 1900, 0, false );
    add_image_size( 'test4', 1800, 0, false );
    add_image_size( 'test3', 1700, 0, false );
    add_image_size( 'test2', 1600, 0, false );
    add_image_size( 'test1', 1500, 0, false );
    add_image_size( 'test', 123, 123 );
}

I changed out the themes, that did not work. I tried this on a full setup and on a virgin setup with no plugins, nothing made it work. I made the height 0 (for infinite) in the code above, but it also produced the same result when the number matched the width.

The images WordPress DOES generate are the following - by increasing size:

  • 123x88 my add
  • 150x150 WP standard
  • 300x215 "
  • 768x549 "
  • 1024x732 "
  • 1200x858 "
  • 1500x1073 my add
  • 1536x1099 WP standard
  • 2400x1717 my add
  • 2500x1788 "
  • 2600x1860 "
  • 3840x2747 my add

the original is a 7k jpg

So, as you can see it does not generate between 1536 and 2400. The version of WordPress is 5.5.3, with PHP v7.4

I was hoping someone had come across this issue specifically or might have some insight into the workings of WP.

question from:https://stackoverflow.com/questions/65830653/wordpress-add-image-size-not-generating-widths-between-1600px-and-2300px

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...