mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
fixed media field type
This commit is contained in:
parent
3982221e30
commit
540bdac2a6
@ -28,17 +28,27 @@ return [
|
||||
'estimated_pending_time',
|
||||
'default_published_time',
|
||||
'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_height',
|
||||
'picture_width',
|
||||
'picture_height',
|
||||
'add_canvas',
|
||||
'image_canvas_width',
|
||||
'image_canvas_height',
|
||||
'watermark_type',
|
||||
'watermark_text',
|
||||
'watermark_image',
|
||||
'watermark_position',
|
||||
'listing_page_image',
|
||||
'hide_standard_price_field',
|
||||
],
|
||||
],
|
||||
'user' => [
|
||||
|
||||
@ -108,71 +108,6 @@ return [
|
||||
'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' => [
|
||||
'type' => 'anomaly.field_type.file',
|
||||
@ -255,4 +190,102 @@ return [
|
||||
'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' => [
|
||||
'title' => 'Options',
|
||||
],
|
||||
'ads-image' => 'Ads Image',
|
||||
];
|
||||
|
||||
@ -79,21 +79,6 @@ return [
|
||||
'default_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' => [
|
||||
'name' => 'Twitter',
|
||||
],
|
||||
@ -106,18 +91,6 @@ return [
|
||||
'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' => [
|
||||
'name' => 'Listing Page Image',
|
||||
],
|
||||
@ -158,4 +131,49 @@ return [
|
||||
'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)',
|
||||
{
|
||||
paramName: 'upload',
|
||||
resizeWidth: 800,
|
||||
resizeHeight: 600,
|
||||
resizeWidth: settings_image['resize_width'],
|
||||
resizeHeight: settings_image['resize_height'],
|
||||
autoProcessQueue: true,
|
||||
parallelUploads: 1,
|
||||
resizeMethod: 'contain',
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'choose_folder' => 'Which folder would you like to upload to?',
|
||||
'upload' => 'Add İmages | Upload İmages | Attach a photo',
|
||||
'choose_files' => 'Which files would you like to use?',
|
||||
'choose_folder' => 'Which folder would you like to upload to?',
|
||||
'upload' => 'Add İmages | Upload İmages | Attach a photo',
|
||||
'choose_files' => 'Which files would you like to use?',
|
||||
'no_files_selected' => 'No files selected.',
|
||||
'no_uploads' => 'No files uploaded.',
|
||||
'overwrite' => 'has already been uploaded. Would you like to overwrite it?',
|
||||
'uploading' => 'Uploading',
|
||||
'loading' => 'Loading',
|
||||
'no_uploads' => 'No files uploaded.',
|
||||
'overwrite' => 'has already been uploaded. Would you like to overwrite it?',
|
||||
'uploading' => 'Uploading',
|
||||
'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>
|
||||
<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\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Visiosoft\MediaFieldType\Table\FileTableBuilder;
|
||||
use Visiosoft\MediaFieldType\Table\UploadTableBuilder;
|
||||
use Anomaly\FilesModule\File\FileUploader;
|
||||
use Anomaly\FilesModule\Folder\Command\GetFolder;
|
||||
@ -13,7 +12,6 @@ use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Intervention\Image\Facades\Image as WaterMark;
|
||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||
use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
||||
|
||||
/**
|
||||
@ -25,16 +23,22 @@ use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
||||
*/
|
||||
class UploadController extends AdminController
|
||||
{
|
||||
public $uploader;
|
||||
|
||||
public $folders;
|
||||
|
||||
public $files;
|
||||
|
||||
use DispatchesJobs;
|
||||
|
||||
/**
|
||||
* Return the uploader.
|
||||
*
|
||||
* @param UploadTableBuilder $table
|
||||
* @param $folder
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function __construct(FileUploader $uploader, FolderRepositoryInterface $folders, FileRepositoryInterface $files)
|
||||
{
|
||||
$this->uploader = $uploader;
|
||||
$this->folders = $folders;
|
||||
$this->files = $files;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(UploadTableBuilder $table, $folder)
|
||||
{
|
||||
return $this->view->make(
|
||||
@ -46,90 +50,102 @@ class UploadController extends AdminController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a file.
|
||||
*
|
||||
* @param FileUploader $uploader
|
||||
* @param FolderRepositoryInterface $folders
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function upload(FileUploader $uploader, FolderRepositoryInterface $folders, SettingRepositoryInterface $settings, FileRepositoryInterface $files)
|
||||
public function upload()
|
||||
{
|
||||
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');
|
||||
$position = $settings->value('visiosoft.module.advs::watermark_position');
|
||||
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||
->resize(null, setting_value('visiosoft.field_type.media::imageResizeH', 600),function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||
->resize(null, setting_value('visiosoft.module.advs::picture_height'),function ($constraint) {
|
||||
$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();
|
||||
|
||||
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();
|
||||
});
|
||||
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(
|
||||
setting_value('visiosoft.field_type.media::imageCanvasW', 800),
|
||||
setting_value('visiosoft.field_type.media::imageCanvasH', 600),
|
||||
$settings_value['image_canvas_width'], $settings_value['image_canvas_height'],
|
||||
'center', false, 'fff'
|
||||
);
|
||||
|
||||
$mdImg->resizeCanvas(
|
||||
setting_value('visiosoft.module.advs::picture_width', 400),
|
||||
setting_value('visiosoft.module.advs::picture_height', 300),
|
||||
$settings_value['medium_image_width'], $settings_value['medium_image_height'],
|
||||
'center', false, 'fff'
|
||||
);
|
||||
}
|
||||
foreach ([$fullImg, $mdImg] as $index => $image) {
|
||||
if ($watermarktype == 'image') {
|
||||
$watermarkimage_id = $settings->value('visiosoft.module.advs::watermark_image');
|
||||
$watermarkimage = $files->find($watermarkimage_id);
|
||||
if ($watermarkimage != null) {
|
||||
|
||||
$image_types = array('full' => $fullImg, 'medium' => $mdImg);
|
||||
|
||||
foreach ($image_types as $key => $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, $position);
|
||||
$image->insert($watermark, $settings_value['watermark_position']);
|
||||
}
|
||||
|
||||
} else {
|
||||
$watermarktext = $settings->value('visiosoft.module.advs::watermark_text');
|
||||
$v = "top";
|
||||
$h = "center";
|
||||
$w = $image->width() / 2;
|
||||
$h1 = $image->height() / 2;
|
||||
$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->size($font_size);
|
||||
$font->align($h);
|
||||
$font->valign($v);
|
||||
});
|
||||
}
|
||||
if ($index === 0) {
|
||||
if ($key === "full") {
|
||||
$fileName = $file->getAttributes()['name'];
|
||||
} else {
|
||||
$fileName = 'md-' . $file->getAttributes()['name'];
|
||||
|
||||
$files->create([
|
||||
'folder_id' => $this->request->get('folder'),
|
||||
'name' => $fileName,
|
||||
'disk_id' => 1,
|
||||
'size' => $image->filesize(),
|
||||
'mime_type' => $image->mime,
|
||||
'extension' => $image->extension,
|
||||
]);
|
||||
$this->createFile($this->request->get('folder'),$fileName,$image);
|
||||
}
|
||||
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return $table->setUploaded(explode(',', $this->request->get('uploaded')))
|
||||
@ -158,4 +174,16 @@ class UploadController extends AdminController
|
||||
}
|
||||
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