Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为wordpress image.php设置最大图像大小(kb)_Php_Wordpress - Fatal编程技术网

为wordpress image.php设置最大图像大小(kb)

为wordpress image.php设置最大图像大小(kb),php,wordpress,Php,Wordpress,您好,我正在寻找一种方法来设置wordpress wp admin/includes/image.php中图像的最大上传大小(kb) 这是我在image.php中找到的代码,但我并不真正理解它,关于如何设置以kb或字节为单位的最大值有什么想法吗 /** * Filter the image sizes automatically generated when uploading an image. * * @since 2.9.0 * * @param array $sizes An

您好,我正在寻找一种方法来设置wordpress wp admin/includes/image.php中图像的最大上传大小(kb)

这是我在image.php中找到的代码,但我并不真正理解它,关于如何设置以kb或字节为单位的最大值有什么想法吗

/**
 * Filter the image sizes automatically generated when uploading an image.
 *
 * @since 2.9.0
 *
 * @param array $sizes An associative array of image sizes.
 */
$sizes = apply_filters( 'intermediate_image_sizes_advanced', $sizes );

if ( $sizes ) {
    $editor = wp_get_image_editor( $file );

    if ( ! is_wp_error( $editor ) )
        $metadata['sizes'] = $editor->multi_resize( $sizes );
} else {
    $metadata['sizes'] = array();
}
下面是调用image.php文件的代码。也许有一种方法可以添加if条件来检查文件大小:

/**
 * Uploads file
 *
 * @access public
 * @param array $file
 * @return int
 */
public static function addFile($file, $exts=array()) {
    require_once(ABSPATH.'wp-admin/includes/image.php');
    $attachment=array(
        'ID' => 0,
    );

    $slug='file';
    if(empty($exts)) {
        $exts=array('jpg', 'jpeg', 'png');
        $slug='image';
    }

    foreach($exts as $ext) {
        $exts[]=strtolower($ext);
        $exts[]=strtoupper($ext);
    }

    if(!empty($file['name'])) {
        $uploads=wp_upload_dir();
        $filetype=wp_check_filetype($file['name'], null);
        $filename=wp_unique_filename($uploads['path'], $slug.'-1.'.$filetype['ext']);
        $filepath=$uploads['path'].'/'.$filename;           

        //validate file
        if (!in_array($filetype['ext'], array_unique($exts))) {
            ThemexInterface::$messages[]=__('Files with this extension are not allowed', 'mercadoyorubacambio');
        } else if(move_uploaded_file($file['tmp_name'], $filepath)) {

我有一些“黑客”给你

您只需创建一个php.ini文件并将其上载到/wp admin文件夹中。然后添加以下内容:

内存限制=32M

上载\u最大\u文件大小=32M

立柱最大尺寸=32米

文件上传=打开

您可以通过将“32M”更改为另一个值来设置最大尺寸


希望这对您有用。

转到lib\external\file\u uploader.php第65行var$sizeLimit=10485760;第68行函数构造(数组$allowedExtensions=array(),$sizeLimit=10485760){只需更改限制。为避免错误,请使用字节转换器Web谢谢,我会检查它并让您知道它是如何工作的。我找不到该文件,但在dreamweaver中进行搜索时,我在wp includes/js/pupload/handlers.min.js:
函数文件上载(a,b){var c=104857600,d=parseInt(a.settings.max_file_size,10)
我将检查更改是否有效,并让您知道如果不起作用,我将其设置为1M,但我可以上载2mb文件