protected function DropzoneJsEbWidget::validateExtension in DropzoneJS 8
Same name and namespace in other branches
- 8.2 modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php \Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\DropzoneJsEbWidget::validateExtension()
Validate extension.
Because while validating we don't have a file object yet, we can't use file_validate_extensions directly. That's why we make a copy of that function here and switch the file argument with filename argument.
Parameters
string $filename: The filename we want to test.
string $extensions: A space separated list of extensions.
Return value
bool True if the file's extension is a valid one. False otherwise.
File
- modules/
eb_widget/ src/ Plugin/ EntityBrowser/ Widget/ DropzoneJsEbWidget.php, line 334
Class
- DropzoneJsEbWidget
- Provides an Entity Browser widget that uploads new files.
Namespace
Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\WidgetCode
protected function validateExtension($filename, $extensions) {
$regex = '/\\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i';
if (!preg_match($regex, $filename)) {
return FALSE;
}
return TRUE;
}