Set maximum image size in kb for wordpress image.php -
hi im looking way set maximum upload size in kb images in wordpress wp-admin/includes/image.php
this code found in image.php don't understand it, ideas on how set maximum value in kb or bytes
/** * filter image sizes automatically generated when uploading image. * * @since 2.9.0 * * @param array $sizes 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(); } here code calls image.php file maybe there way add if conditional check file size:
/** * 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 $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 extension not allowed', 'mercadoyorubacambio'); } else if(move_uploaded_file($file['tmp_name'], $filepath)) {
i got 'hack' you.
all need create php.ini file , upload /wp-admin folder. add following:
memory_limit = 32m
upload_max_filesize = 32m
post_max_size = 32m
file_uploads = on
you can set max size changing '32m' value
hope works you.
Comments
Post a Comment