diff --git a/README.md b/README.md index 682a572c..703dfbfa 100644 --- a/README.md +++ b/README.md @@ -253,9 +253,8 @@ TrueFalse::make('Social Media', 'display_social_media') use Extended\ACF\Fields\File; File::make('Resturant Menu', 'menu') - ->instructions('Add the menu pdf file.') ->instructions('Add the menu **pdf** file.') - ->mimeTypes(['pdf']) + ->acceptedFileTypes(['pdf']) ->library('all') // all, uploadedTo ->minSize('400 KB') ->maxSize(5) // MB if entered as int @@ -270,7 +269,7 @@ use Extended\ACF\Fields\Gallery; Gallery::make('Images') ->instructions('Add the gallery images.') - ->mimeTypes(['jpg', 'jpeg', 'png']) + ->acceptedFileTypes(['jpg', 'jpeg', 'png']) ->minHeight(500) ->maxHeight(1400) ->minWidth(1000) @@ -292,7 +291,7 @@ use Extended\ACF\Fields\Image; Image::make('Background Image') ->instructions('Add an image in at least 12000x100px and only in the formats **jpg**, **jpeg** or **png**.') - ->mimeTypes(['jpg', 'jpeg', 'png']) + ->acceptedFileTypes(['jpg', 'jpeg', 'png']) ->minHeight(500) ->maxHeight(1400) ->minWidth(1000) @@ -881,32 +880,46 @@ The upgrade guide provides information about the breaking changes in the package 10\. The `width` method has been split into two methods `minWidth` and `maxWidth`. ```diff --Gallery::make('Background')->width(100, 1000) -+Gallery::make('Background')->minWidth(100)->maxWidth(1000) +-Image::make('Background')->width(100, 1000) ++Image::make('Background')->minWidth(100)->maxWidth(1000) ``` -11\. The `CharacterLimit` trait has been renamed to `MaxLength`. +11\. The `mimeTypes` method has been renamed to `acceptedFileTypes`. + +```diff +-File::make('Background')->mimeTypes(['pdf']) ++File::make('Background')->acceptedFileTypes(['pdf']) +``` + +12\. The `MimeTypes` trait has been renamed to `FileTypes`. + +```diff +-use Extended\ACF\Fields\Settings\MimeTypes; ++use Extended\ACF\Fields\Settings\FileTypes; +``` + +13\. The `CharacterLimit` trait has been renamed to `MaxLength`. ```diff -use Extended\ACF\Fields\Settings\CharacterLimit; +use Extended\ACF\Fields\Settings\MaxLength; ``` -12\. The `Pending` trait has been renamed to `Affixable`. +14\. The `Pending` trait has been renamed to `Affixable`. ```diff -use Extended\ACF\Fields\Settings\Pending; +use Extended\ACF\Fields\Settings\Affixable; ``` -13\. The `Writable` trait has been renamed to `Immutable`. +15\. The `Writable` trait has been renamed to `Immutable`. ```diff -use Extended\ACF\Fields\Settings\Writable; +use Extended\ACF\Fields\Settings\Immutable; ``` -14\. The `SubFields` trait has been renamed to `Fields`. +16\. The `SubFields` trait has been renamed to `Fields`. ```diff -use Extended\ACF\Fields\Settings\SubFields; diff --git a/src/Fields/File.php b/src/Fields/File.php index d6f81770..c660ddc5 100644 --- a/src/Fields/File.php +++ b/src/Fields/File.php @@ -15,9 +15,9 @@ use Extended\ACF\Fields\Settings\ConditionalLogic; use Extended\ACF\Fields\Settings\FileSize; +use Extended\ACF\Fields\Settings\FileTypes; use Extended\ACF\Fields\Settings\Instructions; use Extended\ACF\Fields\Settings\Library; -use Extended\ACF\Fields\Settings\MimeTypes; use Extended\ACF\Fields\Settings\Required; use Extended\ACF\Fields\Settings\ReturnFormat; use Extended\ACF\Fields\Settings\Wrapper; @@ -28,7 +28,7 @@ class File extends Field use FileSize; use Instructions; use Library; - use MimeTypes; + use FileTypes; use Required; use ReturnFormat; use Wrapper; diff --git a/src/Fields/Gallery.php b/src/Fields/Gallery.php index d46e23e4..61e29699 100644 --- a/src/Fields/Gallery.php +++ b/src/Fields/Gallery.php @@ -16,9 +16,9 @@ use Extended\ACF\Fields\Settings\ConditionalLogic; use Extended\ACF\Fields\Settings\Dimensions; use Extended\ACF\Fields\Settings\FileSize; +use Extended\ACF\Fields\Settings\FileTypes; use Extended\ACF\Fields\Settings\Instructions; use Extended\ACF\Fields\Settings\Library; -use Extended\ACF\Fields\Settings\MimeTypes; use Extended\ACF\Fields\Settings\MinMax; use Extended\ACF\Fields\Settings\PreviewSize; use Extended\ACF\Fields\Settings\Required; @@ -33,7 +33,7 @@ class Gallery extends Field use FileSize; use Instructions; use Library; - use MimeTypes; + use FileTypes; use MinMax; use PreviewSize; use Required; diff --git a/src/Fields/Image.php b/src/Fields/Image.php index 4bce3026..e1cd717d 100644 --- a/src/Fields/Image.php +++ b/src/Fields/Image.php @@ -16,9 +16,9 @@ use Extended\ACF\Fields\Settings\ConditionalLogic; use Extended\ACF\Fields\Settings\Dimensions; use Extended\ACF\Fields\Settings\FileSize; +use Extended\ACF\Fields\Settings\FileTypes; use Extended\ACF\Fields\Settings\Instructions; use Extended\ACF\Fields\Settings\Library; -use Extended\ACF\Fields\Settings\MimeTypes; use Extended\ACF\Fields\Settings\PreviewSize; use Extended\ACF\Fields\Settings\Required; use Extended\ACF\Fields\Settings\ReturnFormat; @@ -31,7 +31,7 @@ class Image extends Field use FileSize; use Instructions; use Library; - use MimeTypes; + use FileTypes; use PreviewSize; use Required; use ReturnFormat; diff --git a/src/Fields/Settings/MimeTypes.php b/src/Fields/Settings/FileTypes.php similarity index 60% rename from src/Fields/Settings/MimeTypes.php rename to src/Fields/Settings/FileTypes.php index 82090966..6f4c5c74 100644 --- a/src/Fields/Settings/MimeTypes.php +++ b/src/Fields/Settings/FileTypes.php @@ -13,11 +13,15 @@ namespace Extended\ACF\Fields\Settings; -trait MimeTypes +trait FileTypes { - public function mimeTypes(array $mimeTypes): static + public function acceptedFileTypes(array|string $types): static { - $this->settings['mime_types'] = implode(',', $mimeTypes); + if (is_string($types)) { + $types = [$types]; + } + + $this->settings['mime_types'] = implode(',', $types); return $this; } diff --git a/tests/Fields/FileTest.php b/tests/Fields/FileTest.php index 5f8e5a1b..d4f5b7bb 100644 --- a/tests/Fields/FileTest.php +++ b/tests/Fields/FileTest.php @@ -25,10 +25,10 @@ public function testType() $this->assertSame('file', $field['type']); } - public function testMimeTypes() + public function testAcceptedFileTypes() { - $field = File::make('Mime Types')->mimeTypes(['jpg', 'pdf'])->get(); - $this->assertSame('jpg,pdf', $field['mime_types']); + $field = File::make('File Accepted File Types')->acceptedFileTypes(['image/jpg', 'application/pdf'])->get(); + $this->assertSame('image/jpg,application/pdf', $field['mime_types']); } public function testReturnFormat()