mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
fixed media field
This commit is contained in:
parent
853f629ffb
commit
76b515a1b3
@ -10,4 +10,5 @@ return [
|
||||
'uploading' => 'Uploading',
|
||||
'loading' => 'Loading',
|
||||
'error_upload' => 'There was a problem uploading the file.',
|
||||
'error_upload_docs' => 'There is no document upload support. Please contact your system administrator!',
|
||||
];
|
||||
|
||||
@ -10,4 +10,5 @@ return [
|
||||
'uploading' => 'Yükleme',
|
||||
'loading' => 'Yükleniyor',
|
||||
'error_upload' => 'Dosyayı yüklerken bir sorun oluştu.',
|
||||
'error_upload_docs' => 'Döküman yükleme desteği bulunmamaktadır.Lütfen sistem yöneticiniz ile iletişim kurunuz!',
|
||||
];
|
||||
|
||||
@ -50,104 +50,105 @@ class UploadController extends AdminController
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$doc_folder = app(FolderRepositoryInterface::class)->findBySlug('ads_documents')->id;
|
||||
$mimes = explode('/', $this->request->file('upload')->getMimeType());
|
||||
$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 {
|
||||
$file = $this->uploader->upload($this->request->file('upload'), $this->folders->find($doc_folder));
|
||||
}
|
||||
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_documentsssssss')) {
|
||||
$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) {
|
||||
if ($mimes[0] == 'image'){
|
||||
if ($mimes[0] == 'image') {
|
||||
|
||||
$settings_key = [
|
||||
'image_resize_backend',
|
||||
'full_image_width',
|
||||
'full_image_height',
|
||||
'medium_image_width',
|
||||
'medium_image_height',
|
||||
'thumbnail_width',
|
||||
'thumbnail_height',
|
||||
'add_canvas',
|
||||
'image_canvas_width',
|
||||
'image_canvas_height',
|
||||
'watermark_type',
|
||||
'watermark_text',
|
||||
'watermark_image',
|
||||
'watermark_position'
|
||||
];
|
||||
$settings_key = [
|
||||
'image_resize_backend',
|
||||
'full_image_width',
|
||||
'full_image_height',
|
||||
'medium_image_width',
|
||||
'medium_image_height',
|
||||
'thumbnail_width',
|
||||
'thumbnail_height',
|
||||
'add_canvas',
|
||||
'image_canvas_width',
|
||||
'image_canvas_height',
|
||||
'watermark_type',
|
||||
'watermark_text',
|
||||
'watermark_image',
|
||||
'watermark_position'
|
||||
];
|
||||
|
||||
$settings_value = array();
|
||||
$settings_value = array();
|
||||
|
||||
foreach ($settings_key as $key) {
|
||||
$settings_value[$key] = setting_value('visiosoft.module.advs::' . $key);
|
||||
}
|
||||
foreach ($settings_key as $key) {
|
||||
$settings_value[$key] = setting_value('visiosoft.module.advs::' . $key);
|
||||
}
|
||||
|
||||
|
||||
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath());
|
||||
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath());
|
||||
|
||||
if ($settings_value['image_resize_backend']) {
|
||||
$fullImg = $fullImg->resize(null, $settings_value['full_image_height'],
|
||||
function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
}
|
||||
if ($settings_value['image_resize_backend']) {
|
||||
$fullImg = $fullImg->resize(null, $settings_value['full_image_height'],
|
||||
function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
}
|
||||
|
||||
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||
->resize(null, $settings_value['medium_image_height'], function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||
->resize(null, $settings_value['medium_image_height'], function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
|
||||
|
||||
if ($settings_value['add_canvas']) {
|
||||
if ($settings_value['add_canvas']) {
|
||||
|
||||
$fullImg->resizeCanvas(
|
||||
$settings_value['image_canvas_width'], $settings_value['image_canvas_height'],
|
||||
'center', false, 'fff'
|
||||
);
|
||||
$fullImg->resizeCanvas(
|
||||
$settings_value['image_canvas_width'], $settings_value['image_canvas_height'],
|
||||
'center', false, 'fff'
|
||||
);
|
||||
|
||||
$mdImg->resizeCanvas(
|
||||
$settings_value['medium_image_width'], $settings_value['medium_image_height'],
|
||||
'center', false, 'fff'
|
||||
);
|
||||
}
|
||||
$mdImg->resizeCanvas(
|
||||
$settings_value['medium_image_width'], $settings_value['medium_image_height'],
|
||||
'center', false, 'fff'
|
||||
);
|
||||
}
|
||||
|
||||
$image_types = array('full' => $fullImg, 'medium' => $mdImg);
|
||||
$image_types = array('full' => $fullImg, 'medium' => $mdImg);
|
||||
|
||||
foreach ($image_types as $key => $image) {
|
||||
foreach ($image_types as $key => $image) {
|
||||
|
||||
if ($settings_value['watermark_type'] == 'image') {
|
||||
if ($settings_value['watermark_type'] == 'image') {
|
||||
|
||||
if ($watermarkimage = $this->files->find($settings_value['watermark_image'])) {
|
||||
$watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path());
|
||||
$image->insert($watermark, $settings_value['watermark_position']);
|
||||
}
|
||||
if ($watermarkimage = $this->files->find($settings_value['watermark_image'])) {
|
||||
$watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path());
|
||||
$image->insert($watermark, $settings_value['watermark_position']);
|
||||
}
|
||||
|
||||
} else {
|
||||
$v = "top";
|
||||
$h = "center";
|
||||
$w = $image->width() / 2;
|
||||
$h1 = $image->height() / 2;
|
||||
$font_size = $w / 20;
|
||||
$image->text($settings_value['watermark_text'], $w, $h1, function ($font) use ($v, $h, $font_size) {
|
||||
$font->file(public_path('Antonio-Bold.ttf'));
|
||||
$font->size($font_size);
|
||||
$font->align($h);
|
||||
$font->valign($v);
|
||||
});
|
||||
}
|
||||
if ($key === "full") {
|
||||
$fileName = $file->getAttributes()['name'];
|
||||
} else {
|
||||
$fileName = 'md-' . $file->getAttributes()['name'];
|
||||
} else {
|
||||
$v = "top";
|
||||
$h = "center";
|
||||
$w = $image->width() / 2;
|
||||
$h1 = $image->height() / 2;
|
||||
$font_size = $w / 20;
|
||||
$image->text($settings_value['watermark_text'], $w, $h1, function ($font) use ($v, $h, $font_size) {
|
||||
$font->file(public_path('Antonio-Bold.ttf'));
|
||||
$font->size($font_size);
|
||||
$font->align($h);
|
||||
$font->valign($v);
|
||||
});
|
||||
}
|
||||
if ($key === "full") {
|
||||
$fileName = $file->getAttributes()['name'];
|
||||
} else {
|
||||
$fileName = 'md-' . $file->getAttributes()['name'];
|
||||
|
||||
$this->createFile($this->request->get('folder'),$fileName,$image);
|
||||
}
|
||||
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
||||
}
|
||||
}
|
||||
$this->createFile($this->request->get('folder'), $fileName, $image);
|
||||
}
|
||||
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
||||
}
|
||||
}
|
||||
return $this->response->json($file->getAttributes());
|
||||
}
|
||||
|
||||
@ -183,15 +184,15 @@ class UploadController extends AdminController
|
||||
return response()->json(['status' => 'error']);
|
||||
}
|
||||
|
||||
public function createFile($folder, $filename, $image = null)
|
||||
{
|
||||
$this->files->create([
|
||||
'folder_id' => $folder,
|
||||
'name' => $filename,
|
||||
'disk_id' => 1,
|
||||
'size' => $image->filesize(),
|
||||
'mime_type' => $image->mime,
|
||||
'extension' => $image->extension,
|
||||
]);
|
||||
}
|
||||
public function createFile($folder, $filename, $image = null)
|
||||
{
|
||||
$this->files->create([
|
||||
'folder_id' => $folder,
|
||||
'name' => $filename,
|
||||
'disk_id' => 1,
|
||||
'size' => $image->filesize(),
|
||||
'mime_type' => $image->mime,
|
||||
'extension' => $image->extension,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user