Skip to content

Commit fa50b4c

Browse files
committed
Add support for uploading SVGs
1 parent 4f80b2b commit fa50b4c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/backend/traits/UploadableWidget.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
<?php namespace Backend\Traits;
22

3-
use Str;
3+
use ApplicationException;
4+
use Event;
45
use File;
6+
use Illuminate\Filesystem\FilesystemAdapter;
57
use Lang;
6-
use Event;
7-
use Config;
8-
use Storage;
98
use Request;
109
use Response;
11-
use ApplicationException;
10+
use Str;
1211
use System\Classes\MediaLibrary;
13-
use Illuminate\Filesystem\FilesystemAdapter;
1412
use Winter\Storm\Filesystem\Definitions as FileDefinitions;
13+
use Winter\Storm\Support\Svg;
1514

1615
/**
1716
* Uploadable Widget Trait
@@ -124,6 +123,11 @@ protected function onUploadDirect(): \Illuminate\Http\Response
124123

125124
$filePath = $this->uploadableGetUploadPath($fileName);
126125

126+
// Filter SVG files
127+
if (pathinfo($filePath, PATHINFO_EXTENSION) === 'svg') {
128+
file_put_contents($sourcePath, Svg::extract($sourcePath));
129+
}
130+
127131
$this->uploadableGetDisk()->put($filePath, File::get($sourcePath));
128132

129133
/**

0 commit comments

Comments
 (0)