wordpress 出现上传媒体文件 最大值是0的情况,多是php.ini 里面禁用了 ini_get 函数,
解决方式是,手动设置个值,在wp-include/media.php 里面
function wp_max_upload_size() { return 1024 * 1024 * 2 ; // phpsir 修改 最大2M $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); /** * Filter the maximum upload size allowed in php.ini. * * @since 2.5.0 * * @param int $size Max upload size limit in bytes. * @param int $u_bytes Maximum upload filesize in bytes. * @param int $p_bytes Maximum size of POST data in bytes. */ return apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes ); }