mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
parent
8ede266bc2
commit
c6e5c6635b
@ -25,6 +25,10 @@ return [
|
||||
'default_published_time',
|
||||
'default_adv_limit',
|
||||
'default_GET',
|
||||
'thumbnail_width',
|
||||
'thumbnail_height',
|
||||
'picture_width',
|
||||
'picture_height',
|
||||
'watermark_type',
|
||||
'watermark_text',
|
||||
'watermark_image',
|
||||
|
||||
@ -111,6 +111,30 @@ return [
|
||||
'default_value' => 0,
|
||||
],
|
||||
],
|
||||
'thumbnail_width' => [
|
||||
'type' => 'anomaly.field_type.integer',
|
||||
'config' => [
|
||||
'default_value' => 270,
|
||||
],
|
||||
],
|
||||
'thumbnail_height' => [
|
||||
'type' => 'anomaly.field_type.integer',
|
||||
'config' => [
|
||||
'default_value' => 180,
|
||||
],
|
||||
],
|
||||
'picture_width' => [
|
||||
'type' => 'anomaly.field_type.integer',
|
||||
'config' => [
|
||||
'default_value' => 900,
|
||||
],
|
||||
],
|
||||
'picture_height' => [
|
||||
'type' => 'anomaly.field_type.integer',
|
||||
'config' => [
|
||||
'default_value' => 600,
|
||||
],
|
||||
],
|
||||
'watermark_type' => [
|
||||
'type' => 'anomaly.field_type.select',
|
||||
'bind' => 'adv.watermark_type',
|
||||
|
||||
@ -82,6 +82,18 @@ return [
|
||||
'default_GET' => [
|
||||
'name' => 'Default Ad GET',
|
||||
],
|
||||
'thumbnail_width' => [
|
||||
'name' => 'Thumbnail Width',
|
||||
],
|
||||
'thumbnail_height' => [
|
||||
'name' => 'Thumbnail Height',
|
||||
],
|
||||
'picture_width' => [
|
||||
'name' => 'Picture Width',
|
||||
],
|
||||
'picture_height' => [
|
||||
'name' => 'Picture Height',
|
||||
],
|
||||
'twitter' => [
|
||||
'name' => 'Twitter',
|
||||
],
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<a href="{{ image }}"><img src="{{ img('visiosoft.theme.base::images/no-image.png').url }}"></a>
|
||||
{% else %}
|
||||
{% for image in adv.getViewPhotoUrl %}
|
||||
<a href="{{ image }}"><img src="{{ image }}"></a>
|
||||
<a href="{{ adv.getMediumPhotoUrl(image) }}"></a>
|
||||
{% if loop.index == 1 %}
|
||||
{% set advPhoto = image %}
|
||||
{% endif %}
|
||||
|
||||
@ -19,6 +19,11 @@ class AdvPresenter extends EntryPresenter
|
||||
|
||||
}
|
||||
|
||||
public function getMediumPhotoUrl($fullPhotoUrl)
|
||||
{
|
||||
$mediumPhotoUrl = pathinfo($fullPhotoUrl);
|
||||
return $mediumPhotoUrl['dirname'] . '/md-' . $mediumPhotoUrl['basename'];
|
||||
}
|
||||
|
||||
public function isAdVideo()
|
||||
{
|
||||
|
||||
@ -1,14 +1,16 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv;
|
||||
|
||||
use Anomaly\FilesModule\File\Contract\FileRepositoryInterface;
|
||||
use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
|
||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||
use Visiosoft\CatsModule\Category\CategoryModel;
|
||||
use Visiosoft\AdvsModule\Category\Contract\CategoryRepositoryInterface;
|
||||
use Visiosoft\DopingsModule\Doping\DopingModel;
|
||||
use Visiosoft\LocationModule\City\CityModel;
|
||||
use Visiosoft\LocationModule\Country\CountryModel;
|
||||
|
||||
@ -22,6 +24,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* @var FileRepositoryInterface
|
||||
*/
|
||||
private $fileRepository;
|
||||
|
||||
/**
|
||||
* @var FolderRepositoryInterface
|
||||
*/
|
||||
private $folderRepository;
|
||||
|
||||
/**
|
||||
* Create a new AdvRepository instance.
|
||||
*
|
||||
@ -29,11 +41,15 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
*/
|
||||
public function __construct(
|
||||
AdvModel $model,
|
||||
SettingRepositoryInterface $settings
|
||||
SettingRepositoryInterface $settings,
|
||||
FileRepositoryInterface $fileRepository,
|
||||
FolderRepositoryInterface $folderRepository
|
||||
)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->settings = $settings;
|
||||
$this->fileRepository = $fileRepository;
|
||||
$this->folderRepository = $folderRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,8 +307,32 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
public function cover_image_update($adv)
|
||||
{
|
||||
if (count($adv->files) != 0) {
|
||||
$file_url = 'files/images/' . $adv->files[0]->name;
|
||||
$adv->update(['cover_photo' => $file_url]);
|
||||
$fileName = 'tn-' . $adv->files[0]->name;
|
||||
$folder = $this->folderRepository->findBySlug('images');
|
||||
$thumbnail = $this->fileRepository->findByNameAndFolder($fileName, $folder);
|
||||
if (!$thumbnail) {
|
||||
// Create thumbnail image
|
||||
$image = Image::make($adv->files[0]->url());
|
||||
$image->resize(
|
||||
setting_value('visiosoft.module.advs::thumbnail_width'),
|
||||
setting_value('visiosoft.module.advs::thumbnail_height')
|
||||
);
|
||||
$fileName = 'tn-' . $adv->files[0]->name;
|
||||
$image->save(app_storage_path() . '/files-module/local/images/' . $fileName);
|
||||
|
||||
// Create file entry for the image
|
||||
$this->fileRepository->create([
|
||||
'folder_id' => $folder->getId(),
|
||||
'name' => $fileName,
|
||||
'disk_id' => 1,
|
||||
'size' => $image->filesize(),
|
||||
'mime_type' => $image->mime,
|
||||
'extension' => $image->extension,
|
||||
]);
|
||||
|
||||
$file_url = 'files/images/' . $fileName;
|
||||
$adv->update(['cover_photo' => $file_url]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,38 +59,63 @@ class UploadController extends AdminController
|
||||
|
||||
$watermarktype = $settings->value('visiosoft.module.advs::watermark_type');
|
||||
$position = $settings->value('visiosoft.module.advs::watermark_position');
|
||||
$img = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||
->resize(setting_value('visiosoft.field_type.media::imageResizeW', null), setting_value('visiosoft.field_type.media::imageResizeH', 600))
|
||||
->resizeCanvas(setting_value('visiosoft.field_type.media::imageCanvasW', 800), setting_value('visiosoft.field_type.media::imageCanvasH', 600), 'center', false, 'fff');
|
||||
if ($watermarktype == 'image') {
|
||||
|
||||
$watermarkimage_id = $settings->value('visiosoft.module.advs::watermark_image');
|
||||
$watermarkimage = $files->find($watermarkimage_id);
|
||||
$w = $img->width();
|
||||
if ($watermarkimage != null) {
|
||||
$watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path());
|
||||
$img->insert($watermark, $position);
|
||||
$fullImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||
->resize(
|
||||
setting_value('visiosoft.field_type.media::imageResizeW', null),
|
||||
setting_value('visiosoft.field_type.media::imageResizeH', 600)
|
||||
)
|
||||
->resizeCanvas(
|
||||
setting_value('visiosoft.field_type.media::imageCanvasW', 800),
|
||||
setting_value('visiosoft.field_type.media::imageCanvasH', 600),
|
||||
'center',
|
||||
false,
|
||||
'fff'
|
||||
);
|
||||
$mdImg = WaterMark::make($this->request->file('upload')->getRealPath())
|
||||
->resize(
|
||||
setting_value('visiosoft.module.advs::picture_width'),
|
||||
setting_value('visiosoft.module.advs::picture_height')
|
||||
);
|
||||
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) {
|
||||
$watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path());
|
||||
$image->insert($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) {
|
||||
$font->file(public_path('Antonio-Bold.ttf'));
|
||||
$font->size($font_size);
|
||||
$font->align($h);
|
||||
$font->valign($v);
|
||||
});
|
||||
}
|
||||
if ($index === 0) {
|
||||
$fileName = $file->getAttributes()['name'];
|
||||
} else {
|
||||
$fileName = 'md-' . $file->getAttributes()['name'];
|
||||
|
||||
} else {
|
||||
$watermarktext = $settings->value('visiosoft.module.advs::watermark_text');
|
||||
$v = "top";
|
||||
$h = "center";
|
||||
$w = $img->width() / 2;
|
||||
$h1 = $img->height() / 2;
|
||||
$font_size = $w / 20;
|
||||
$img->text($watermarktext, $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);
|
||||
});
|
||||
|
||||
$files->create([
|
||||
'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);
|
||||
}
|
||||
|
||||
$img->save(app_storage_path() . '/files-module/local/images/' . $file->getAttributes()['name']);
|
||||
return $this->response->json($file->getAttributes());
|
||||
|
||||
}
|
||||
|
||||
return $this->response->json(['error' => 'There was a problem uploading the file.'], 500);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user