How I tried to fix “Suggested maximum image size is 2560 pixels” error in WordPress

While uploading an image I got:

Tried to add the following to www/wp-content/themes/star/functions.php:

1
2
3
4
5
6
7
// completely disable image size threshold
add_filter( 'big_image_size_threshold', '__return_false' );
 
//switch to GD
add_filter('wp_image_editors', function($editors) {
    return ['WP_Image_Editor_GD', 'WP_Image_Editor_Imagick'];
});

but it did not help.

and installed PHP GD module:

1
2
sudo apt-get install php7.4-gd
sudo service php7.4-fpm restart

but it did not help.

GD module is enabled:

1
2
3
4
5
6
7
8
9
10
11
12
<?php
 
// Show all information, defaults to INFO_ALL
phpinfo();
 
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
 
print_r(gd_info());
 
?>