When a form field is not bound to a data object and an image is uploaded, the file is saved in the database as type File rather than Image.
The issue lies in FileAttachmentField.php in the getFileClass function at line 1309:
if ($defaultClass == "Image" && $this->config()->upgrade_images && !Injector::inst()->get($class) instanceof Image) {
The issue is the $defaultClass will never contain "Image" as the class returned by File::get_class_for_file_extension() would be SilverStripe\Assets\Image, therefore, the line should be:
if ($defaultClass == Image::class && $this->config()->upgrade_images && !Injector::inst()->get($class) instanceof Image) {
Unless I misunderstood something!
When a form field is not bound to a data object and an image is uploaded, the file is saved in the database as type File rather than Image.
The issue lies in FileAttachmentField.php in the getFileClass function at line 1309:
if ($defaultClass == "Image" && $this->config()->upgrade_images && !Injector::inst()->get($class) instanceof Image) {The issue is the $defaultClass will never contain "Image" as the class returned by File::get_class_for_file_extension() would be SilverStripe\Assets\Image, therefore, the line should be:
if ($defaultClass == Image::class && $this->config()->upgrade_images && !Injector::inst()->get($class) instanceof Image) {Unless I misunderstood something!