From ea7f5d6d2fe672cd67d4bb1fc725453fc929c848 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 11 Jun 2019 18:08:42 +0200 Subject: [PATCH] #2810 --- src/app/Magic/Fields/Files.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/Magic/Fields/Files.php b/src/app/Magic/Fields/Files.php index e98ffd1..52c1c23 100644 --- a/src/app/Magic/Fields/Files.php +++ b/src/app/Magic/Fields/Files.php @@ -9,11 +9,20 @@ class Files extends Field protected $_multiple = false; protected $_adminType = 'dropzone_media'; protected $_databaseType = 'text'; - protected $_collection = 'files'; - protected $_thumbCollection = 'thumbs'; + protected $_collection = null; + protected $_thumbCollection = null; public function getDefaultAttributes() { - return array_merge(parent::getDefaultAttributes(), ['mime_types' => $this->_mimeTypes, 'collection' => $this->_collection, 'thumb_collection' => $this->_thumbCollection]); + $collection = $this->_collection; + if (null === $collection) { + $collection = $this->getAttribute('name'); + } + $thumbCollection = $this->_thumbCollection; + if (null === $thumbCollection) { + $thumbCollection = $collection . '_thumbs'; + } + + return array_merge(parent::getDefaultAttributes(), ['mime_types' => $this->_mimeTypes, 'collection' => $collection, 'thumb_collection' => $thumbCollection]); } } -- 2.39.5