diff --git a/application/controllers/Items.php b/application/controllers/Items.php index 4ae98f918..d75f54643 100644 --- a/application/controllers/Items.php +++ b/application/controllers/Items.php @@ -669,13 +669,11 @@ class Items extends Secure_Controller { //Load upload library $config = array('upload_path' => './uploads/item_pics/', - 'allowed_types' => 'gif|jpg|png', - 'max_size' => '100', - 'max_width' => '640', - 'max_height' => '480' - ); - - $this->load->library('upload', $config); + 'allowed_types' => $this->config->item('image_allowed_types'), + 'max_size' => $this->config->item('image_max_size'), + 'max_width' => $this->config->item('image_max_width'), + 'max_height' => $this->config->item('image_max_height')); + $this->load->library('upload', $config); $this->upload->do_upload('item_image'); return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '

'.$this->lang->line('upload_no_file_selected').'

'); diff --git a/application/migrations/20200508000000_image_upload_defaults.php b/application/migrations/20200508000000_image_upload_defaults.php new file mode 100644 index 000000000..c69c0273d --- /dev/null +++ b/application/migrations/20200508000000_image_upload_defaults.php @@ -0,0 +1,27 @@ + 'allowed_types', 'value' => 'gif|jpg|png'), + array('key' => 'max_height', 'value' => '480'), + array('key' => 'max_size', 'value' => '100'), + array('key' => 'max_width', 'value' => '640')); + + $this->db->insert_batch('app_config', $image_values); + } + + public function down() + { + $this->db->where_in('key', array('allowed_types','max_height','max_size','max_width')); + $this->db->delete('app_config'); + } +} +?> diff --git a/application/views/configs/general_config.php b/application/views/configs/general_config.php index 77882894a..99ecfb8e1 100644 --- a/application/views/configs/general_config.php +++ b/application/views/configs/general_config.php @@ -143,7 +143,7 @@ 'type' => 'number', 'min' => 128, 'max' => 3840, - 'value' => $this->config->item('max_image_width'), + 'value' => $this->config->item('image_max_width'), 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => $this->lang->line('config_image_max_width_tooltip'))); @@ -160,7 +160,7 @@ 'type' => 'number', 'min' => 128, 'max' => 3840, - 'value' => $this->config->item('max_image_height'), + 'value' => $this->config->item('image_max_height'), 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => $this->lang->line('config_image_max_height_tooltip'))); @@ -177,7 +177,7 @@ 'type' => 'number', 'min' => 128, 'max' => 2048, - 'value' => $this->config->item('max_image_size'), + 'value' => $this->config->item('image_max_size'), 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => $this->lang->line('config_image_max_size_tooltip')));