public function save() { if (isset($_POST['delete_' . $this->name])) { $last_data = get_post_meta($this->post_id, $this->name, true); if ($last_data == "") { $last_data = false; } if ($last_data !== false) { custom_fields::remove_image($this->field['directory'], $last_data); update_post_meta($this->post_id, $this->name, ""); } } if (isset($_FILES[$this->name])) { $file = $_FILES[$this->name]; $make_circular = isset($this->field['make_circular']) ? $this->field['make_circular'] : false; $data = custom_fields::upload_image_set_both($file, $this->field['directory'], $this->field['width'], $this->field['height'], $make_circular); $wp_upload_dir = wp_upload_dir(); $directory_used = $wp_upload_dir['url'] . '/' . $this->field['directory']; if (strlen($data) > 0) { update_post_meta($this->post_id, $this->name, $data); update_post_meta($this->post_id, $this->name . '_dir', $directory_used); } unset($_FILES[$this->name]); } }