public function deleteAttachment($id) {
		if(!StorageSettings::deleteFromStorage()) {
			return $id;
		}

		$data = wp_get_attachment_metadata($id);
		if(isset($data['file']) && !isset($data['s3'])) {
			return $id;
		}

		if($this->client && $this->client->enabled()) {
			if(!isset($data['file'])) {
				$file = get_attached_file($id);
				if($file) {
					if(strpos($file, 'http') === 0) {
						$pi = parse_url($file);
						$file = trim($pi['path'], '/');
						if(0 === strpos($file, $this->client->bucket())) {
							$file = substr($file, strlen($this->client->bucket())).'';
							$file = trim($file, '/');
						}
					} else {
						$pi = pathinfo($file);
						$upload_info = wp_upload_dir();
						$upload_path = $upload_info['basedir'];

						$file = trim(str_replace($upload_path, '', $pi['dirname']), '/').'/'.$pi['basename'];
					}

					$this->deleteFile($file);
				}
			} else {
			    $deletedFiles = [];

			    $deletedFiles[] = $data['s3']['key'];
				$this->deleteFile($data['s3']['key']);

				if(isset($data['sizes'])) {
					$pathParts = explode('/', $data['s3']['key']);
					array_pop($pathParts);
					$path_base = implode('/', $pathParts);

					foreach($data['sizes'] as $key => $size) {
						$file = arrayPath($size,'s3/key', false);
						if (!$file) {
						    $file = $path_base.'/'.$size['file'];
                        }

                        if (in_array($file, $deletedFiles)) {
					        Logger::info("File '$file' has already been deleted.");
					        continue;
                        }

                        $this->deleteFile($file);

						$deletedFiles[] = $file;
					}
				}
			}
		}

		return $id;
	}