Skip to content

Commit

Permalink
Add support for uploading SVGs
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeTowers committed Jul 7, 2023
1 parent 4f80b2b commit fa50b4c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions modules/backend/traits/UploadableWidget.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?php namespace Backend\Traits;

use Str;
use ApplicationException;
use Event;
use File;
use Illuminate\Filesystem\FilesystemAdapter;
use Lang;
use Event;
use Config;
use Storage;
use Request;
use Response;
use ApplicationException;
use Str;
use System\Classes\MediaLibrary;
use Illuminate\Filesystem\FilesystemAdapter;
use Winter\Storm\Filesystem\Definitions as FileDefinitions;
use Winter\Storm\Support\Svg;

/**
* Uploadable Widget Trait
Expand Down Expand Up @@ -124,6 +123,11 @@ protected function onUploadDirect(): \Illuminate\Http\Response

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

// Filter SVG files
if (pathinfo($filePath, PATHINFO_EXTENSION) === 'svg') {
file_put_contents($sourcePath, Svg::extract($sourcePath));
}

$this->uploadableGetDisk()->put($filePath, File::get($sourcePath));

/**
Expand Down

0 comments on commit fa50b4c

Please sign in to comment.