mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
fixed media field type
This commit is contained in:
parent
3982221e30
commit
540bdac2a6
@ -28,17 +28,27 @@ return [
|
|||||||
'estimated_pending_time',
|
'estimated_pending_time',
|
||||||
'default_published_time',
|
'default_published_time',
|
||||||
'default_GET',
|
'default_GET',
|
||||||
'add_canvas',
|
'hide_standard_price_field',
|
||||||
|
'listing_page_image',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'ads-image' => [
|
||||||
|
'title' => 'visiosoft.module.advs::section.ads-image',
|
||||||
|
'fields' => [
|
||||||
|
'image_resize_backend',
|
||||||
|
'full_image_width',
|
||||||
|
'full_image_height',
|
||||||
|
'medium_image_width',
|
||||||
|
'medium_image_height',
|
||||||
'thumbnail_width',
|
'thumbnail_width',
|
||||||
'thumbnail_height',
|
'thumbnail_height',
|
||||||
'picture_width',
|
'add_canvas',
|
||||||
'picture_height',
|
'image_canvas_width',
|
||||||
|
'image_canvas_height',
|
||||||
'watermark_type',
|
'watermark_type',
|
||||||
'watermark_text',
|
'watermark_text',
|
||||||
'watermark_image',
|
'watermark_image',
|
||||||
'watermark_position',
|
'watermark_position',
|
||||||
'listing_page_image',
|
|
||||||
'hide_standard_price_field',
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'user' => [
|
'user' => [
|
||||||
|
|||||||
@ -108,71 +108,6 @@ return [
|
|||||||
'default_value' => 0,
|
'default_value' => 0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'thumbnail_width' => [
|
|
||||||
'type' => 'anomaly.field_type.integer',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 270,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'add_canvas' => [
|
|
||||||
'type' => 'anomaly.field_type.boolean',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => true,
|
|
||||||
'mode' => 'checkbox',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'thumbnail_height' => [
|
|
||||||
'type' => 'anomaly.field_type.integer',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 180,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'picture_width' => [
|
|
||||||
'type' => 'anomaly.field_type.integer',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 600,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'picture_height' => [
|
|
||||||
'type' => 'anomaly.field_type.integer',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 400,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'watermark_type' => [
|
|
||||||
'type' => 'anomaly.field_type.select',
|
|
||||||
'bind' => 'adv.watermark_type',
|
|
||||||
'env' => 'ADV_WATERMARK_TYPE',
|
|
||||||
'required' => true,
|
|
||||||
'config' => [
|
|
||||||
'options' => ['image' => 'Image', 'text' => 'Text'],
|
|
||||||
'default_value' => 'text',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'watermark_text' => [
|
|
||||||
'type' => 'anomaly.field_type.text',
|
|
||||||
'bind' => 'adv.watermark_text',
|
|
||||||
'env' => 'ADV_WATERMARK_TEXT',
|
|
||||||
],
|
|
||||||
'watermark_image' => [
|
|
||||||
'type' => 'anomaly.field_type.file',
|
|
||||||
'bind' => 'adv.watermark_image',
|
|
||||||
'env' => 'ADV_WATERMARK_IMAGE',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => '',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'watermark_position' => [
|
|
||||||
'type' => 'anomaly.field_type.select',
|
|
||||||
'bind' => 'adv.watermark_position',
|
|
||||||
'env' => 'ADV_WATERMARK_POSITION',
|
|
||||||
'required' => true,
|
|
||||||
'config' => [
|
|
||||||
'options' => ['top-right' => 'Top Right', 'top-left' => 'Top Left', 'bottom-right' => 'Bottom Right',
|
|
||||||
'bottom-left' => 'Bottom Left', 'center' => 'Middle'],
|
|
||||||
'default_value' => 'top-right',
|
|
||||||
]
|
|
||||||
],
|
|
||||||
|
|
||||||
'listing_page_image' => [
|
'listing_page_image' => [
|
||||||
'type' => 'anomaly.field_type.file',
|
'type' => 'anomaly.field_type.file',
|
||||||
@ -255,4 +190,102 @@ return [
|
|||||||
'default_value' => 15,
|
'default_value' => 15,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
//Image Settings
|
||||||
|
|
||||||
|
'image_resize_backend' => [
|
||||||
|
'type' => 'anomaly.field_type.boolean',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'full_image_width' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 800,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
'full_image_height' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 600,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'medium_image_width' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 600,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'medium_image_height' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 400,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'thumbnail_width' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 270,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'thumbnail_height' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 180,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'add_canvas' => [
|
||||||
|
'type' => 'anomaly.field_type.boolean',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'image_canvas_width' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 800,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'image_canvas_height' => [
|
||||||
|
'type' => 'anomaly.field_type.integer',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => 600,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'watermark_type' => [
|
||||||
|
'type' => 'anomaly.field_type.select',
|
||||||
|
'bind' => 'adv.watermark_type',
|
||||||
|
'env' => 'ADV_WATERMARK_TYPE',
|
||||||
|
'required' => true,
|
||||||
|
'config' => [
|
||||||
|
'options' => ['image' => 'Image', 'text' => 'Text'],
|
||||||
|
'default_value' => 'text',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'watermark_text' => [
|
||||||
|
'type' => 'anomaly.field_type.text',
|
||||||
|
'bind' => 'adv.watermark_text',
|
||||||
|
'env' => 'ADV_WATERMARK_TEXT',
|
||||||
|
],
|
||||||
|
'watermark_image' => [
|
||||||
|
'type' => 'anomaly.field_type.file',
|
||||||
|
'bind' => 'adv.watermark_image',
|
||||||
|
'env' => 'ADV_WATERMARK_IMAGE',
|
||||||
|
'config' => [
|
||||||
|
'default_value' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'watermark_position' => [
|
||||||
|
'type' => 'anomaly.field_type.select',
|
||||||
|
'bind' => 'adv.watermark_position',
|
||||||
|
'env' => 'ADV_WATERMARK_POSITION',
|
||||||
|
'required' => true,
|
||||||
|
'config' => [
|
||||||
|
'options' => ['top-right' => 'Top Right', 'top-left' => 'Top Left', 'bottom-right' => 'Bottom Right',
|
||||||
|
'bottom-left' => 'Bottom Left', 'center' => 'Middle'],
|
||||||
|
'default_value' => 'top-right',
|
||||||
|
]
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -44,4 +44,5 @@ return [
|
|||||||
'options' => [
|
'options' => [
|
||||||
'title' => 'Options',
|
'title' => 'Options',
|
||||||
],
|
],
|
||||||
|
'ads-image' => 'Ads Image',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -79,21 +79,6 @@ return [
|
|||||||
'default_GET' => [
|
'default_GET' => [
|
||||||
'name' => 'Default Ad GET',
|
'name' => 'Default Ad GET',
|
||||||
],
|
],
|
||||||
'add_canvas' => [
|
|
||||||
'name' => 'Add Canvas',
|
|
||||||
],
|
|
||||||
'thumbnail_width' => [
|
|
||||||
'name' => 'Thumbnail Width',
|
|
||||||
],
|
|
||||||
'thumbnail_height' => [
|
|
||||||
'name' => 'Thumbnail Height',
|
|
||||||
],
|
|
||||||
'picture_width' => [
|
|
||||||
'name' => 'Picture Width',
|
|
||||||
],
|
|
||||||
'picture_height' => [
|
|
||||||
'name' => 'Picture Height',
|
|
||||||
],
|
|
||||||
'twitter' => [
|
'twitter' => [
|
||||||
'name' => 'Twitter',
|
'name' => 'Twitter',
|
||||||
],
|
],
|
||||||
@ -106,18 +91,6 @@ return [
|
|||||||
'google' => [
|
'google' => [
|
||||||
'name' => 'Google',
|
'name' => 'Google',
|
||||||
],
|
],
|
||||||
'watermark_type' => [
|
|
||||||
'name' => 'Watermark Type',
|
|
||||||
],
|
|
||||||
'watermark_text' => [
|
|
||||||
'name' => 'Watermark Text',
|
|
||||||
],
|
|
||||||
'watermark_image' => [
|
|
||||||
'name' => 'Watermark Image',
|
|
||||||
],
|
|
||||||
'watermark_position' => [
|
|
||||||
'name' => 'Watermark Position',
|
|
||||||
],
|
|
||||||
'listing_page_image' => [
|
'listing_page_image' => [
|
||||||
'name' => 'Listing Page Image',
|
'name' => 'Listing Page Image',
|
||||||
],
|
],
|
||||||
@ -158,4 +131,49 @@ return [
|
|||||||
'popular_ads_limit' => [
|
'popular_ads_limit' => [
|
||||||
'name' => 'Popular Ads Limit',
|
'name' => 'Popular Ads Limit',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
//Image
|
||||||
|
|
||||||
|
'image_resize_backend' => [
|
||||||
|
'name' => 'Image Resize Backend',
|
||||||
|
],
|
||||||
|
'full_image_width' => [
|
||||||
|
'name' => 'Full Image Width',
|
||||||
|
],
|
||||||
|
'full_image_height' => [
|
||||||
|
'name' => 'Full Image Height',
|
||||||
|
],
|
||||||
|
'medium_image_width' => [
|
||||||
|
'name' => 'Medium Image Width',
|
||||||
|
],
|
||||||
|
'medium_image_height' => [
|
||||||
|
'name' => 'Medium Image Height',
|
||||||
|
],
|
||||||
|
'thumbnail_width' => [
|
||||||
|
'name' => 'Thumbnail Width',
|
||||||
|
],
|
||||||
|
'thumbnail_height' => [
|
||||||
|
'name' => 'Thumbnail Height',
|
||||||
|
],
|
||||||
|
'add_canvas' => [
|
||||||
|
'name' => 'Add Canvas',
|
||||||
|
],
|
||||||
|
'image_canvas_width' => [
|
||||||
|
'name' => 'Image Canvas Width',
|
||||||
|
],
|
||||||
|
'image_canvas_height' => [
|
||||||
|
'name' => 'Image Canvas Height',
|
||||||
|
],
|
||||||
|
'watermark_type' => [
|
||||||
|
'name' => 'Watermark Type',
|
||||||
|
],
|
||||||
|
'watermark_text' => [
|
||||||
|
'name' => 'Watermark Text',
|
||||||
|
],
|
||||||
|
'watermark_image' => [
|
||||||
|
'name' => 'Watermark Image',
|
||||||
|
],
|
||||||
|
'watermark_position' => [
|
||||||
|
'name' => 'Watermark Position',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
'imageCanvasW' => [
|
|
||||||
'type' => 'anomaly.field_type.integer',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 800,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'imageCanvasH' => [
|
|
||||||
'type' => 'anomaly.field_type.integer',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 600,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'imageResizeH' => [
|
|
||||||
'type' => 'anomaly.field_type.integer',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 600,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
@ -16,8 +16,8 @@ $(function () {
|
|||||||
var dropzone = new Dropzone('.dropzone:not(data-initialized)',
|
var dropzone = new Dropzone('.dropzone:not(data-initialized)',
|
||||||
{
|
{
|
||||||
paramName: 'upload',
|
paramName: 'upload',
|
||||||
resizeWidth: 800,
|
resizeWidth: settings_image['resize_width'],
|
||||||
resizeHeight: 600,
|
resizeHeight: settings_image['resize_height'],
|
||||||
autoProcessQueue: true,
|
autoProcessQueue: true,
|
||||||
parallelUploads: 1,
|
parallelUploads: 1,
|
||||||
resizeMethod: 'contain',
|
resizeMethod: 'contain',
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'choose_folder' => 'Which folder would you like to upload to?',
|
'choose_folder' => 'Which folder would you like to upload to?',
|
||||||
'upload' => 'Add İmages | Upload İmages | Attach a photo',
|
'upload' => 'Add İmages | Upload İmages | Attach a photo',
|
||||||
'choose_files' => 'Which files would you like to use?',
|
'choose_files' => 'Which files would you like to use?',
|
||||||
'no_files_selected' => 'No files selected.',
|
'no_files_selected' => 'No files selected.',
|
||||||
'no_uploads' => 'No files uploaded.',
|
'no_uploads' => 'No files uploaded.',
|
||||||
'overwrite' => 'has already been uploaded. Would you like to overwrite it?',
|
'overwrite' => 'has already been uploaded. Would you like to overwrite it?',
|
||||||
'uploading' => 'Uploading',
|
'uploading' => 'Uploading',
|
||||||
'loading' => 'Loading',
|
'loading' => 'Loading',
|
||||||
|
'error_upload' => 'There was a problem uploading the file.',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
return [
|
|
||||||
'imageCanvasW' => [
|
|
||||||
'name' => 'Image Canvas Width'
|
|
||||||
],
|
|
||||||
'imageCanvasH' => [
|
|
||||||
'name' => 'Image Canvas Height'
|
|
||||||
],
|
|
||||||
'imageResizeW' => [
|
|
||||||
'name' => 'Image Resize Width'
|
|
||||||
],
|
|
||||||
'imageResizeH' => [
|
|
||||||
'name' => 'Image Resize Height'
|
|
||||||
],
|
|
||||||
];
|
|
||||||
@ -14,3 +14,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
var settings_image = {
|
||||||
|
'resize_width':"{{ setting_value('visiosoft.module.advs::full_image_width') }}",
|
||||||
|
'resize_height':"{{ setting_value('visiosoft.module.advs::full_image_height') }}"
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@ -5,7 +5,6 @@ use Anomaly\Streams\Platform\Model\Files\FilesFilesEntryModel;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Visiosoft\MediaFieldType\Table\FileTableBuilder;
|
|
||||||
use Visiosoft\MediaFieldType\Table\UploadTableBuilder;
|
use Visiosoft\MediaFieldType\Table\UploadTableBuilder;
|
||||||
use Anomaly\FilesModule\File\FileUploader;
|
use Anomaly\FilesModule\File\FileUploader;
|
||||||
use Anomaly\FilesModule\Folder\Command\GetFolder;
|
use Anomaly\FilesModule\Folder\Command\GetFolder;
|
||||||
@ -13,7 +12,6 @@ use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
|
|||||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Intervention\Image\Facades\Image as WaterMark;
|
use Intervention\Image\Facades\Image as WaterMark;
|
||||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
|
||||||
use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,16 +23,22 @@ use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
|||||||
*/
|
*/
|
||||||
class UploadController extends AdminController
|
class UploadController extends AdminController
|
||||||
{
|
{
|
||||||
|
public $uploader;
|
||||||
|
|
||||||
|
public $folders;
|
||||||
|
|
||||||
|
public $files;
|
||||||
|
|
||||||
use DispatchesJobs;
|
use DispatchesJobs;
|
||||||
|
|
||||||
/**
|
public function __construct(FileUploader $uploader, FolderRepositoryInterface $folders, FileRepositoryInterface $files)
|
||||||
* Return the uploader.
|
{
|
||||||
*
|
$this->uploader = $uploader;
|
||||||
* @param UploadTableBuilder $table
|
$this->folders = $folders;
|
||||||
* @param $folder
|
$this->files = $files;
|
||||||
* @return \Illuminate\View\View
|
parent::__construct();
|
||||||
*/
|
}
|
||||||
|
|
||||||
public function index(UploadTableBuilder $table, $folder)
|
public function index(UploadTableBuilder $table, $folder)
|
||||||
{
|
{
|
||||||
return $this->view->make(
|
return $this->view->make(
|
||||||
@ -46,90 +50,102 @@ class UploadController extends AdminController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function upload()
|
||||||
* Upload a file.
|
|
||||||
*
|
|
||||||
* @param FileUploader $uploader
|
|
||||||
* @param FolderRepositoryInterface $folders
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
|
||||||
*/
|
|
||||||
public function upload(FileUploader $uploader, FolderRepositoryInterface $folders, SettingRepositoryInterface $settings, FileRepositoryInterface $files)
|
|
||||||
{
|
{
|
||||||
if ($file = $uploader->upload($this->request->file('upload'), $folders->find($this->request->get('folder')))) {
|
$file = $this->uploader->upload($this->request->file('upload'), $this->folders->find($this->request->get('folder')));
|
||||||
|
if ($file) {
|
||||||
|
|
||||||
$watermarktype = $settings->value('visiosoft.module.advs::watermark_type');
|
$settings_key = [
|
||||||
$position = $settings->value('visiosoft.module.advs::watermark_position');
|
'image_resize_backend',
|
||||||
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
'full_image_width',
|
||||||
->resize(null, setting_value('visiosoft.field_type.media::imageResizeH', 600),function ($constraint) {
|
'full_image_height',
|
||||||
$constraint->aspectRatio();
|
'medium_image_width',
|
||||||
});
|
'medium_image_height',
|
||||||
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
'thumbnail_width',
|
||||||
->resize(null, setting_value('visiosoft.module.advs::picture_height'),function ($constraint) {
|
'thumbnail_height',
|
||||||
|
'add_canvas',
|
||||||
|
'image_canvas_width',
|
||||||
|
'image_canvas_height',
|
||||||
|
'watermark_type',
|
||||||
|
'watermark_text',
|
||||||
|
'watermark_image',
|
||||||
|
'watermark_position'
|
||||||
|
];
|
||||||
|
|
||||||
|
$settings_value = array();
|
||||||
|
|
||||||
|
foreach ($settings_key as $key) {
|
||||||
|
$settings_value[$key] = setting_value('visiosoft.module.advs::' . $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$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();
|
$constraint->aspectRatio();
|
||||||
});
|
});
|
||||||
if (setting_value('visiosoft.module.advs::add_canvas')) {
|
}
|
||||||
|
|
||||||
|
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||||
|
->resize(null, $settings_value['medium_image_height'], function ($constraint) {
|
||||||
|
$constraint->aspectRatio();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if ($settings_value['add_canvas']) {
|
||||||
|
|
||||||
$fullImg->resizeCanvas(
|
$fullImg->resizeCanvas(
|
||||||
setting_value('visiosoft.field_type.media::imageCanvasW', 800),
|
$settings_value['image_canvas_width'], $settings_value['image_canvas_height'],
|
||||||
setting_value('visiosoft.field_type.media::imageCanvasH', 600),
|
|
||||||
'center', false, 'fff'
|
'center', false, 'fff'
|
||||||
);
|
);
|
||||||
|
|
||||||
$mdImg->resizeCanvas(
|
$mdImg->resizeCanvas(
|
||||||
setting_value('visiosoft.module.advs::picture_width', 400),
|
$settings_value['medium_image_width'], $settings_value['medium_image_height'],
|
||||||
setting_value('visiosoft.module.advs::picture_height', 300),
|
|
||||||
'center', false, 'fff'
|
'center', false, 'fff'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach ([$fullImg, $mdImg] as $index => $image) {
|
|
||||||
if ($watermarktype == 'image') {
|
$image_types = array('full' => $fullImg, 'medium' => $mdImg);
|
||||||
$watermarkimage_id = $settings->value('visiosoft.module.advs::watermark_image');
|
|
||||||
$watermarkimage = $files->find($watermarkimage_id);
|
foreach ($image_types as $key => $image) {
|
||||||
if ($watermarkimage != null) {
|
|
||||||
|
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());
|
$watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path());
|
||||||
$image->insert($watermark, $position);
|
$image->insert($watermark, $settings_value['watermark_position']);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$watermarktext = $settings->value('visiosoft.module.advs::watermark_text');
|
|
||||||
$v = "top";
|
$v = "top";
|
||||||
$h = "center";
|
$h = "center";
|
||||||
$w = $image->width() / 2;
|
$w = $image->width() / 2;
|
||||||
$h1 = $image->height() / 2;
|
$h1 = $image->height() / 2;
|
||||||
$font_size = $w / 20;
|
$font_size = $w / 20;
|
||||||
$image->text($watermarktext, $w, $h1, function ($font) use ($v, $h, $font_size) {
|
$image->text($settings_value['watermark_text'], $w, $h1, function ($font) use ($v, $h, $font_size) {
|
||||||
$font->file(public_path('Antonio-Bold.ttf'));
|
$font->file(public_path('Antonio-Bold.ttf'));
|
||||||
$font->size($font_size);
|
$font->size($font_size);
|
||||||
$font->align($h);
|
$font->align($h);
|
||||||
$font->valign($v);
|
$font->valign($v);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($index === 0) {
|
if ($key === "full") {
|
||||||
$fileName = $file->getAttributes()['name'];
|
$fileName = $file->getAttributes()['name'];
|
||||||
} else {
|
} else {
|
||||||
$fileName = 'md-' . $file->getAttributes()['name'];
|
$fileName = 'md-' . $file->getAttributes()['name'];
|
||||||
|
|
||||||
$files->create([
|
$this->createFile($this->request->get('folder'),$fileName,$image);
|
||||||
'folder_id' => $this->request->get('folder'),
|
|
||||||
'name' => $fileName,
|
|
||||||
'disk_id' => 1,
|
|
||||||
'size' => $image->filesize(),
|
|
||||||
'mime_type' => $image->mime,
|
|
||||||
'extension' => $image->extension,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->json($file->getAttributes());
|
return $this->response->json($file->getAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->response->json(['error' => 'There was a problem uploading the file.'], 500);
|
return $this->response->json(['error' => trans('visiosoft.field_type.media::message.error_upload')], 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the recently uploaded files.
|
|
||||||
*
|
|
||||||
* @param FileTableBuilder $table
|
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
|
||||||
*/
|
|
||||||
public function recent(UploadTableBuilder $table)
|
public function recent(UploadTableBuilder $table)
|
||||||
{
|
{
|
||||||
return $table->setUploaded(explode(',', $this->request->get('uploaded')))
|
return $table->setUploaded(explode(',', $this->request->get('uploaded')))
|
||||||
@ -158,4 +174,16 @@ class UploadController extends AdminController
|
|||||||
}
|
}
|
||||||
return response()->json(['status' => 'error']);
|
return response()->json(['status' => 'error']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createFile($folder, $filename, $image)
|
||||||
|
{
|
||||||
|
$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