public function render()
{
$this->loadFiles();
$args = $this->arguments;
$seq = $this->seq();
// set default file upload options
$fileuploadOptions = ['previewMaxWidth' => 280, 'previewMaxHeight' => 120, 'previewCrop' => false, 'autoUpload' => false, 'acceptFileTypes' => "(\\.|\\/)(.*)\$", 'maxFileSize' => 5000000, 'replaceFileInput' => false, 'disableImageResize' => true, 'imageCrop' => false, 'imageMaxWidth' => 480, 'imageMaxHeight' => 240];
// set file
if (isset($args['file'])) {
$file = File::find($args['file']);
if ($file === null) {
unset($args['file']);
} else {
$filename = $file->clientname;
$args['file'] = $filename;
}
}
// resolve arguments
$fileuploadOptions = array_merge($fileuploadOptions, array_get($args, 'fileuploadOptions', []));
$args = array_add($args, 'width', 420);
$args = array_add($args, 'height', 240);
array_set($fileuploadOptions, 'previewMaxWidth', $args['width']);
array_set($fileuploadOptions, 'previewMaxHeight', $args['height']);
$types = array_get($args, 'types');
if ($types !== null) {
array_set($fileuploadOptions, 'acceptFileTypes', '(\\.|\\/)(' . implode('|', (array) $types) . ')$');
}
array_set($args, 'fileuploadOptions', $fileuploadOptions);
// render template
$this->template = \View::make($this->view, ['args' => $args, 'seq' => $seq])->render();
return parent::render();
}