我认为您的想法是正确的,即检查是否在连接到的回调中查看了正确的页面upload_size_limit
钩
此代码演示在查看其中一个特殊页面时更改上载大小,否则返回标准的最大上载大小:
function wpse239631_change_upload_size( $u_bytes, $p_bytes ) {
// Array of post IDs where the upload size will be changed.
$special_pages = array(
1829, // change to your page
1800, // change to your page, etc
);
// If we\'re on a special page, change the upload size,
// otherwise, use the default max upload size.
if ( in_array( get_the_ID(), $special_pages ) ) {
return 1024 * 18000;
} else {
return min( $u_bytes, $p_bytes );
}
}
add_filter( \'upload_size_limit\', \'wpse239631_change_upload_size\', 10, 2 );