File tree Expand file tree Collapse file tree 5 files changed +30
-6
lines changed
app/code/Magento/PageBuilder
Model/Config/ContentType/AdditionalData/Provider/Uploader
view/adminhtml/pagebuilder/content_type Expand file tree Collapse file tree 5 files changed +30
-6
lines changed Original file line number Diff line number Diff line change 13
13
14
14
/**
15
15
* Provides maximum file size for uploader
16
+ *
17
+ * Will provide the lower of the following two values:
18
+ * - upload_max_filesize from php.ini config
19
+ * - staticFileSize argument passed to constructor
16
20
*/
17
21
class MaxFileSize implements ProviderInterface
18
22
{
@@ -21,21 +25,36 @@ class MaxFileSize implements ProviderInterface
21
25
*/
22
26
private $ fileSize ;
23
27
28
+ /**
29
+ * @var int
30
+ */
31
+ private $ staticFileSize ;
32
+
24
33
/**
25
34
* @param Size $fileSize
35
+ * @param int $staticFileSize
26
36
*/
27
- public function __construct (Size $ fileSize )
28
- {
37
+ public function __construct (
38
+ Size $ fileSize ,
39
+ $ staticFileSize = null
40
+ ) {
29
41
$ this ->fileSize = $ fileSize ;
42
+ $ this ->staticFileSize = $ staticFileSize ;
30
43
}
31
44
32
45
/**
33
46
* @inheritdoc
34
47
*/
35
48
public function getData (string $ itemName ) : array
36
49
{
50
+ // dynamically set max file size based on the lower of php ini config and static value (if present)
51
+ $ maxFileSize = min (array_filter ([
52
+ $ this ->staticFileSize ?? 0 ,
53
+ $ this ->fileSize ->getMaxFileSize ()
54
+ ]));
55
+
37
56
return [
38
- $ itemName => $ this -> fileSize -> getMaxFileSize ()
57
+ $ itemName => $ maxFileSize
39
58
];
40
59
}
41
60
}
Original file line number Diff line number Diff line change 536
536
</argument >
537
537
</arguments >
538
538
</virtualType >
539
+ <virtualType name =" ImageMaxFileSizeDesktop" type =" Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader\MaxFileSize" >
540
+ <arguments >
541
+ <argument name =" staticFileSize" xsi : type =" number" >4194304</argument >
542
+ </arguments >
543
+ </virtualType >
539
544
</config >
Original file line number Diff line number Diff line change 284
284
<item name =" uploaderConfig" xsi : type =" array" >
285
285
<item name =" isShowImageUploadInstructions" xsi : type =" boolean" >false</item >
286
286
<item name =" isShowImageUploadOptions" xsi : type =" boolean" >true</item >
287
- <item name =" maxFileSize" xsi : type =" object" >Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader\MaxFileSize </item >
287
+ <item name =" maxFileSize" xsi : type =" object" >ImageMaxFileSizeDesktop </item >
288
288
<item name =" allowedExtensions" xsi : type =" string" >jpg jpeg gif png</item >
289
289
<item name =" component" xsi : type =" string" >Magento_PageBuilder/js/form/element/image-uploader</item >
290
290
<item name =" componentType" xsi : type =" string" >imageUploader</item >
Original file line number Diff line number Diff line change 78
78
</appearances >
79
79
<additional_data >
80
80
<item name =" uploaderConfig" xsi : type =" array" >
81
- <item name =" maxFileSize" xsi : type =" object" >Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader\MaxFileSize </item >
81
+ <item name =" maxFileSize" xsi : type =" object" >ImageMaxFileSizeDesktop </item >
82
82
<item name =" allowedExtensions" xsi : type =" string" >jpg jpeg gif png</item >
83
83
<item name =" component" xsi : type =" string" >Magento_PageBuilder/js/form/element/image-uploader</item >
84
84
<item name =" componentType" xsi : type =" string" >imageUploader</item >
Original file line number Diff line number Diff line change 284
284
<item name =" uploaderConfig" xsi : type =" array" >
285
285
<item name =" isShowImageUploadInstructions" xsi : type =" boolean" >false</item >
286
286
<item name =" isShowImageUploadOptions" xsi : type =" boolean" >true</item >
287
- <item name =" maxFileSize" xsi : type =" object" >Magento\PageBuilder\Model\Config\ContentType\AdditionalData\Provider\Uploader\MaxFileSize </item >
287
+ <item name =" maxFileSize" xsi : type =" object" >ImageMaxFileSizeDesktop </item >
288
288
<item name =" allowedExtensions" xsi : type =" string" >jpg jpeg gif png</item >
289
289
<item name =" component" xsi : type =" string" >Magento_PageBuilder/js/form/element/image-uploader</item >
290
290
<item name =" componentType" xsi : type =" string" >imageUploader</item >
You can’t perform that action at this time.
0 commit comments