英文:
Can't fix “Suggested maximum image size is 2560 pixels” error in WordPress
问题
以下是翻译好的部分:
在尝试上传一些大图片时,我遇到了以下问题:
尝试将以下内容添加到 www/wp-content/themes/<我的主题>/functions.php
中:
// 完全禁用图像大小阈值
add_filter('big_image_size_threshold', '__return_false');
// 切换到GD
add_filter('wp_image_editors', function($editors) {
return ['WP_Image_Editor_GD', 'WP_Image_Editor_Imagick'];
});
但是没有成功。
GD模块已启用:
PHP版本:7.4
WordPress版本:6
英文:
While trying to upload some large image I get:
Tried to add the following to www/wp-content/themes/<my theme>/functions.php
:
// 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 without a success.
GD module is enabled:
PHP version: 7.4
WordPress version: 6
答案1
得分: 1
以下是翻译好的部分:
这是一个帮助一个人的链接,他在答案的评论中解释了他是如何使用的:
https://developer.wordpress.org/reference/hooks/big_image_size_threshold/
对于那些在寻找用法的人,这是我在functions.php文件中输入的方式:
function td_big_image_size_threshold( $threshold, $imagesize, $file, $attachment_id ) { return 5000; } add_filter( 'big_image_size_threshold', 'td_big_image_size_threshold', 10, 4 );
如果不是这种情况,你可以前往更新页面并重新安装WordPress。
英文:
There was a similar question here:
https://stackoverflow.com/questions/64157086/how-to-override-suggested-maximum-size-is-2500-pixels-on-media-upload-page-w
And this is the link that helped a guy, he explains how he used it in the comment of an answer:
https://developer.wordpress.org/reference/hooks/big_image_size_threshold/
> For people searching on usage, here is how I entered it in my
> functions.php file: function td_big_image_size_threshold( $threshold,
> $imagesize, $file, $attachment_id ) { return 5000; } add_filter(
> 'big_image_size_threshold', 'td_big_image_size_threshold', 10, 4 );
If that's not the case, you can go to the updates page and reinstall WordPress.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论