Disable Wordpress Big Image Size Scaling

WordPress is amazing and I am a very big fan of it.But the version 5.3 brought me (an many others, 1, 2, 3, 4...) a big

WordPress is amazing and I am a very big fan of it.

But the version 5.3 brought me (an many others, 1, 2, 3, 4...) a big problem with its new forced feature for auto-scaling down big images.

I am trying to disable it (because I do not need/want it and because it is not working) with the following filter:

add_filter( 'big_image_size_threshold', '__return_false' ); 

Where the callback function __return_false() is just a WordPress wrapper function to return false.

But it is not working, I still get an error, which means the feature is not disabled.

Same happens with the recommended plugin. It's not fixing the error.

What error?: Postprocessing failed, please scale your image under 2500px.

I did clean the browser cache, set PHP version to 7.2 and activated mbstring (as suggested by others regarding the same problem).

The error happens for some uploads, not for all of them:

And it has nothing to do with uploading big images.

Here are a few facts describing the issue:

  • I am doing random screenshots of random areas (means random sizes).
  • I am always doing small rectangles (max 800px x 400px)
  • Some images will upload fine.
  • Other images will not.
  • But the specific images that work always work if I retry uploading several times.
  • And the specific images that don't always don't if I retry uploading several times (even when renamig the file).

WordPress is amazing and I am a very big fan of it.

But the version 5.3 brought me (an many others, 1, 2, 3, 4...) a big problem with its new forced feature for auto-scaling down big images.

I am trying to disable it (because I do not need/want it and because it is not working) with the following filter:

add_filter( 'big_image_size_threshold', '__return_false' ); 

Where the callback function __return_false() is just a WordPress wrapper function to return false.

But it is not working, I still get an error, which means the feature is not disabled.

Same happens with the recommended plugin. It's not fixing the error.

What error?: Postprocessing failed, please scale your image under 2500px.

I did clean the browser cache, set PHP version to 7.2 and activated mbstring (as suggested by others regarding the same problem).

The error happens for some uploads, not for all of them:

And it has nothing to do with uploading big images.

Here are a few facts describing the issue:

  • I am doing random screenshots of random areas (means random sizes).
  • I am always doing small rectangles (max 800px x 400px)
  • Some images will upload fine.
  • Other images will not.
  • But the specific images that work always work if I retry uploading several times.
  • And the specific images that don't always don't if I retry uploading several times (even when renamig the file).
Share Improve this question edited Dec 3, 2019 at 11:14 Álvaro Franz asked Dec 2, 2019 at 22:17 Álvaro FranzÁlvaro Franz 1,1001 gold badge9 silver badges32 bronze badges 3
  • can you share one or two of the images that worked, and one or two of the images that did not? – Caleb Commented Apr 26, 2020 at 20:18
  • note: took a look at the code in WP core, and did notice that PNGs are excluded from the threshold. – Caleb Commented Apr 26, 2020 at 20:21
  • Dear @Caleb, the images I used for testing where random screenshots with the Windows X native screenshots tool. I deleted those images after doing the tests. But anyway, now everything works fine again with the latest WP version. – Álvaro Franz Commented Apr 27, 2020 at 10:38
Add a comment  | 

5 Answers 5

Reset to default 2

Now it is working as expected (disabled scaling), under the following settings:

In my theme functions.php

add_filter( 'big_image_size_threshold', '__return_false' );

In the WP Media Settings:

I found a client's site where the filter wasn't working. I did a lot of testing on a sandbox site and the filter worked. The website in question is using the Avada theme. Avada has the threshold size built into the theme settings so you can customize what size you would like the scaled image to be. This was overriding where I was trying turn it off in my core plugin.

I first tried adding a priority to the add_filter of 9999 so it would hopefully run later but this doesn't seem to work in this instance (I'm still testing this). I set the threshold size to 0 in Avada and it successfully turned the big image scaling off.

I suggest try adding a priority to see if that helps. If not search the theme and the plugins to see if it is being set there. I know this can be difficult on a live site but I would try using one of the WP default themes and deactivating all the plugins to see if it works. Then reactivate the theme and plugins 1 by 1 to see if there is one causing the issue.

I have used this plugin to test this type of thing on live sites, WP-Staging

To remove the other sizes I found it wasn't enough to set the filter, you also need to unset the new sizes.

// Remove images sizes
function zgwd1010_filter_image_sizes( $sizes) {
    unset( $sizes['1536x1536']); // disable 2x medium-large size
    unset( $sizes['2048x2048']); // disable 2x large size
    return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'zgwd1010_filter_image_sizes');

I have the same issue with not being able to turn off big_image_size_threshold (one of the worst new features WordPress has ever put out) for kicks I tried removing the quotes around return false but it doesn't resolve the issue. The example in Codex does in fact show quotes. https://codex.wordpress/Function_Reference/_return_false

I have opened a ticket in core tracker for this, possible bug.

I don't know why the __return_false doesns't work, but something like this does:

function gc_big_image_size_threshold( $threshold ) {
    return 9999; // new threshold
}
add_filter('big_image_size_threshold', 'gc_big_image_size_threshold', 100, 1);

Had problems recently to make this filter work with '__return_false', but was able to sove the problem. What made the difference for me was adding the priority parameter to the add_filter function (100 in this case), so it will execute later.

add_filter( 'big_image_size_threshold', '__return_false', 100, 1 );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744353310a4570103.html

相关推荐

  • Disable Wordpress Big Image Size Scaling

    WordPress is amazing and I am a very big fan of it.But the version 5.3 brought me (an many others, 1, 2, 3, 4...) a big

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信