You are here

protected function YamlFormManagedFileBase::getMaxFileSize in YAML Form 8

Get max file size for an element.

Parameters

array $element: An element.

Return value

int Max file size.

1 call to YamlFormManagedFileBase::getMaxFileSize()
YamlFormManagedFileBase::prepare in src/Plugin/YamlFormElement/YamlFormManagedFileBase.php
Prepare an element to be rendered within a form.

File

src/Plugin/YamlFormElement/YamlFormManagedFileBase.php, line 422

Class

YamlFormManagedFileBase
Provides a base class form 'managed_file' elements.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

protected function getMaxFileSize(array $element) {

  // Set max file size.
  $max_filesize = \Drupal::config('yamlform.settings')
    ->get('file.default_max_filesize') ?: file_upload_max_size();
  $max_filesize = Bytes::toInt($max_filesize);
  if (!empty($element['#max_filesize'])) {
    $max_filesize = min($max_filesize, Bytes::toInt($element['#max_filesize']) * 1024 * 1024);
  }
  return $max_filesize;
}