Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: more default image extensions (#6250)

Mathias Mogensenee3054b35547
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/custom_cover_picker_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/custom_cover_picker_bloc.dart
index 316f2ddd8f..9ead1ff3f4 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/custom_cover_picker_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/custom_cover_picker_bloc.dart
@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/startup/startup.dart';
+import 'package:appflowy/util/default_extensions.dart';
import 'package:appflowy/workspace/application/settings/prelude.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_result/appflowy_result.dart';
@@ -23,8 +24,6 @@ class CoverImagePickerBloc
_dispatch();
}
- static const allowedExtensions = ['jpg', 'png', 'jpeg'];
-
void _dispatch() {
on<CoverImagePickerEvent>(
(event, emit) async {
@@ -128,7 +127,7 @@ class CoverImagePickerBloc
final result = await getIt<FilePickerService>().pickFiles(
dialogTitle: LocaleKeys.document_plugins_cover_addLocalImage.tr(),
type: FileType.image,
- allowedExtensions: allowedExtensions,
+ allowedExtensions: defaultImageExtensions,
);
if (result != null && result.files.isNotEmpty) {
return result.files.first.path;
@@ -176,7 +175,7 @@ class CoverImagePickerBloc
if (ext != null && ext.isNotEmpty) {
ext = ext.substring(1);
}
- if (allowedExtensions.contains(ext)) {
+ if (defaultImageExtensions.contains(ext)) {
return ext;
}
return null;
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/upload_image_menu/widgets/upload_image_file_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/upload_image_menu/widgets/upload_image_file_widget.dart
index 991a7cb0b9..ae508c0072 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/upload_image_menu/widgets/upload_image_file_widget.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/image/upload_image_menu/widgets/upload_image_file_widget.dart
@@ -1,20 +1,22 @@
+import 'package:flutter/material.dart';
+
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/shared/permission/permission_checker.dart';
import 'package:appflowy/startup/startup.dart';
+import 'package:appflowy/util/default_extensions.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_editor/appflowy_editor.dart' hide Log;
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/file_picker/file_picker_service.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flowy_infra_ui/style_widget/hover.dart';
-import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
class UploadImageFileWidget extends StatelessWidget {
const UploadImageFileWidget({
super.key,
required this.onPickFiles,
- this.allowedExtensions = const ['jpg', 'png', 'jpeg'],
+ this.allowedExtensions = defaultImageExtensions,
this.allowMultipleImages = false,
});
diff --git a/frontend/appflowy_flutter/lib/util/default_extensions.dart b/frontend/appflowy_flutter/lib/util/default_extensions.dart
new file mode 100644
index 0000000000..36bbdcb6b4
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/util/default_extensions.dart
@@ -0,0 +1,15 @@
+/// List of default file extensions used for images.
+///
+/// This is used to make sure that only images that are allowed are picked/uploaded. The extensions
+/// should be supported by Flutter, to avoid causing issues.
+///
+/// See [Image-class documentation](https://api.flutter.dev/flutter/widgets/Image-class.html)
+///
+const List<String> defaultImageExtensions = [
+ 'jpg',
+ 'png',
+ 'jpeg',
+ 'gif',
+ 'webp',
+ 'bmp',
+];