Skip to content

Commit dfeded3

Browse files
authored
fix: return default value for FieldWithFileSize.maxFileSize (#443)
* chore: update composer dev-deps * fix: check if classes are loaded by a different autoloader * chore: add props * ci: replace `docker-compose` with `docker compose` * fix: return default value for `FieldWithFileSize.maxFileSize` * chore: fix changelog
1 parent d190465 commit dfeded3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
## [Unreleased]
44

55
- fix: Check if classes are loaded by a different autoloader before attempting to autoload them. H/t @cvanh
6+
- fix: Return `wp_max_upload_size()` instead of `null` if `GfFieldWithFileSizeSetting.maxFileSize` is `null`. H/t @Gytjarek
67
- ci: Replace calls to `docker-compose` with `docker compose`.
78

8-
99
## v0.13.0
1010

1111
**:warning: This release contains multiple breaking changes.**

src/Type/WPInterface/FieldSetting/FieldWithFileSize.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public static function get_fields(): array {
3636
'maxFileSize' => [
3737
'type' => 'Int',
3838
'description' => __( 'The maximum size (in MB) an uploaded file may be .', 'wp-graphql-gravity-forms' ),
39+
'resolve' => static function ( $source ) {
40+
// Fall back to the WP max upload size if the field setting is not set, to mimic GF frontend behavior.
41+
return ! empty( $source->maxFileSize ) ? (int) $source->maxFileSize : ( wp_max_upload_size() / 1048576 );
42+
},
3943
],
4044
];
4145
}

0 commit comments

Comments
 (0)