SVG support

This commit is contained in:
Fatih Alp 2021-06-28 18:00:37 +03:00
parent 586595e43c
commit af52530b1d
2 changed files with 21 additions and 8 deletions

View File

@ -294,10 +294,17 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
public function cover_image_update($adv)
{
if (count($adv->files) != 0) {
$fileName = 'tn-' . $adv->files[0]->name;
$fileName = $adv->files[0]->name;
$ext = explode('.',$fileName);
if ($ext[1] != 'svg') {
$fileName = 'tn-' . $fileName;
}
$folder = $this->folderRepository->findBySlug('images');
$thumbnail = $this->fileRepository->findByNameAndFolder($fileName, $folder);
if (!$thumbnail) {
if (!$thumbnail AND $ext[1] != 'svg') {
// Create thumbnail image
$image = Image::make(file_get_contents($adv->files[0]->make()->url()));
$image->resize(

View File

@ -50,14 +50,20 @@ class UploadController extends AdminController
public function upload()
{
$mimes = explode('/', $this->request->file('upload')->getMimeType());
if ($mimes[0] == 'image') {
$path = $_FILES['upload']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);
if($ext == 'svg') {
$mimes [0] = 'svg';
$file = $this->uploader->upload($this->request->file('upload'), $this->folders->find($this->request->get('folder')));
} else if ($doc_folder = app(FolderRepositoryInterface::class)->findBySlug('ads_documents')) {
$file = $this->uploader->upload($this->request->file('upload'), $doc_folder);
} else {
return $this->response->json(['error' => trans('visiosoft.field_type.media::message.error_upload_docs')], 500);
$mimes = explode('/', $this->request->file('upload')->getMimeType());
if ($mimes[0] == 'image') {
$file = $this->uploader->upload($this->request->file('upload'), $this->folders->find($this->request->get('folder')));
} else if ($doc_folder = app(FolderRepositoryInterface::class)->findBySlug('ads_documents')) {
$file = $this->uploader->upload($this->request->file('upload'), $doc_folder);
} else {
return $this->response->json(['error' => trans('visiosoft.field_type.media::message.error_upload_docs')], 500);
}
}
if ($file) {