Skip to content

Commit

Permalink
Merge pull request #101 from mostafaznv/dev
Browse files Browse the repository at this point in the history
fix: disable size check for null/zero values
  • Loading branch information
mostafaznv authored Nov 23, 2023
2 parents d48ccc3 + c878517 commit f1cf7f9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/nova-ckeditor.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
* [Image Browser](advanced-usage/configuration/toolbars/toolbar-1/image-browser.md)
* [Audio Browser](advanced-usage/configuration/toolbars/toolbar-1/audio-browser.md)
* [Video Browser](advanced-usage/configuration/toolbars/toolbar-1/video-browser.md)
* [Insert Image Types](advanced-usage/configuration/toolbars/toolbar-1/insert-image-types.md)
* [Insert Image Size](advanced-usage/configuration/toolbars/toolbar-1/insert-image-size.md)
* [Snippets](advanced-usage/configuration/toolbars/toolbar-1/snippets.md)

## ⚪ Other
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
description: toolbars.toolbar-1.image.insert.size
---

# Insert Image Size

<table><thead><tr><th width="351.3333333333333">Property Name</th><th width="166">Type</th><th>Default</th></tr></thead><tbody><tr><td>toolbars.toolbar-1.image.size</td><td>int</td><td>1500</td></tr></tbody></table>

Since `v6.2.0` NovaCkEditor includes a convenient feature that allows users to <mark style="color:red;">drag</mark> and <mark style="color:red;">paste</mark> images directly into the CKEditor field. These images are then automatically uploaded. This functionality simplifies the process of inserting images into your content.

With this option, you have the flexibility to change the maximum <mark style="color:red;">file-size</mark> for uploaded images. The file size is measured in <mark style="color:red;">kilobytes</mark>. Setting this option to <mark style="color:red;">null</mark> or <mark style="color:red;">zero</mark> means that you don't want any size check for uploaded files.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
description: toolbars.toolbar-1.image.insert.types
---

# Insert Image Types

<table><thead><tr><th width="351.3333333333333">Property Name</th><th width="166">Type</th><th>Default</th></tr></thead><tbody><tr><td>toolbars.toolbar-1.image.insert.types</td><td>array</td><td>gif, png, jpg, jpeg, webp</td></tr></tbody></table>

Since `v6.2.0` NovaCkEditor includes a convenient feature that allows users to <mark style="color:red;">drag</mark> and <mark style="color:red;">paste</mark> images directly into the CKEditor field. These images are then automatically uploaded. This functionality simplifies the process of inserting images into your content.

By using this option, you can change accepted mime-types based on your specific requirements.

12 changes: 9 additions & 3 deletions src/Http/Controllers/Api/UploadImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ private function rules(): array
$mimeTypes = implode(',', $options['types']);
}

$rules = [
'required', 'file', "mimes:$mimeTypes"
];

if ($maxSize) {
$rules[] = "max:$maxSize";
}

return [
'upload' => [
'required', 'file', "mimes:$mimeTypes", "max:$maxSize"
],
'upload' => $rules,
];
}

Expand Down

0 comments on commit f1cf7f9

Please sign in to comment.