Stuff
This commit is contained in:
parent
6f2754c7b5
commit
937357b135
6 changed files with 31 additions and 10 deletions
|
@ -62,6 +62,13 @@ class PublicController extends BaseController
|
||||||
return view("themes.gallery.gallery-detail.list", ["gallery" => $gallery, "tenant" => $tenant, "images" => $images]);
|
return view("themes.gallery.gallery-detail.list", ["gallery" => $gallery, "tenant" => $tenant, "images" => $images]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function returnWatermakeFile() {
|
||||||
|
$tenant = Tenant::query()->where("id", "=", session("current_tenant_id"))->firstOrFail();
|
||||||
|
$image = Image::query()->where("id", "=", $tenant->watermark)->firstOrFail();
|
||||||
|
$this->addAccessLog($tenant->id, null, $image->id, "Access", $image->size);
|
||||||
|
return Storage::disk($image->drive)->response($image->path);
|
||||||
|
}
|
||||||
|
|
||||||
public function returnImageFile($tenant_url, $gallery_url, $image_id, Request $request) {
|
public function returnImageFile($tenant_url, $gallery_url, $image_id, Request $request) {
|
||||||
$sizeName = $request->input("size", "medium");
|
$sizeName = $request->input("size", "medium");
|
||||||
if(!array_key_exists($sizeName, self::$size)) {
|
if(!array_key_exists($sizeName, self::$size)) {
|
||||||
|
@ -110,7 +117,7 @@ class PublicController extends BaseController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function addAccessLog(int $tenant, int $gallery, int $image, string $typ, int $size, $type = "general") {
|
private function addAccessLog(int $tenant, $gallery, int $image, string $typ, int $size, $type = "general") {
|
||||||
$access = new Access();
|
$access = new Access();
|
||||||
$access->year = date("Y");
|
$access->year = date("Y");
|
||||||
$access->month = date("m");
|
$access->month = date("m");
|
||||||
|
|
|
@ -77,6 +77,6 @@ class TenantController extends BaseController
|
||||||
$tenant->watermark = $image->id;
|
$tenant->watermark = $image->id;
|
||||||
$tenant->saveOrFail();
|
$tenant->saveOrFail();
|
||||||
|
|
||||||
return "OK";
|
return \redirect("/s/watermark");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,11 @@ class ResizeImage implements ShouldQueue
|
||||||
$img->resize($newWidth, $newHeight);
|
$img->resize($newWidth, $newHeight);
|
||||||
|
|
||||||
//$img->blur(50);
|
//$img->blur(50);
|
||||||
if($this->size > 500 && !is_null($gallery->watermark)) {
|
if($this->size > 500 && !is_null($tenant->watermark)) {
|
||||||
|
Log::info("Add Watermark");
|
||||||
|
|
||||||
$cacheNameWatermark = "";
|
$cacheNameWatermark = "";
|
||||||
$waterMarkImage = Image::query()->where("id", "=", $tenant->watermark);
|
$waterMarkImage = Image::query()->where("id", "=", $tenant->watermark)->firstOrFail();
|
||||||
$watermarkSource = $this->getImage($tenant, $gallery, $waterMarkImage, $cacheNameWatermark);
|
$watermarkSource = $this->getImage($tenant, $gallery, $waterMarkImage, $cacheNameWatermark);
|
||||||
|
|
||||||
$watermark = $manager->make($watermarkSource);
|
$watermark = $manager->make($watermarkSource);
|
||||||
|
@ -103,6 +104,8 @@ class ResizeImage implements ShouldQueue
|
||||||
//$font->angle(45);
|
//$font->angle(45);
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
} else {
|
||||||
|
Log::info("No Watermark");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,7 +118,7 @@ class ResizeImage implements ShouldQueue
|
||||||
//Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString(IMAGETYPE_JPEG, 100));
|
//Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString(IMAGETYPE_JPEG, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getImage($tenant, $gallery, $image, $cacheName) {
|
private function getImage(Tenant $tenant, Gallery $gallery, Image $image, $cacheName) {
|
||||||
if (Storage::disk('cache')->exists($cacheName."_orginal")) {
|
if (Storage::disk('cache')->exists($cacheName."_orginal")) {
|
||||||
$file = Storage::disk("cache")->get($cacheName."_orginal");
|
$file = Storage::disk("cache")->get($cacheName."_orginal");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,6 +21,10 @@ class ImageWatermark extends Migration
|
||||||
Schema::table("tenants", function (Blueprint $table) {
|
Schema::table("tenants", function (Blueprint $table) {
|
||||||
$table->unsignedBigInteger("watermark")->nullable()->default(null);
|
$table->unsignedBigInteger("watermark")->nullable()->default(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::table("access", function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger("gallery")->nullable()->change();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,16 @@
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h1>Watermark</h1>
|
<h1>Watermark</h1>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
<input type="file" name="files[]" class="form-control" >
|
||||||
|
<input type="submit" value="Upload Watermark" class="btn btn-outline-success">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">Current Watermark:<br><img src="/s/watermark/image" style="max-width: 100%;"></div>
|
||||||
|
</div>
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -11,11 +21,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<form method="post" enctype="multipart/form-data">
|
|
||||||
@csrf
|
|
||||||
<input type="file" name="files[]" class="form-control" >
|
|
||||||
<input type="submit" value="Upload Watermark" class="btn btn-outline-success">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ Route::middleware([\App\Http\Middleware\TenanMiddleware::class])->group(function
|
||||||
Route::post("/g/{url}/save", [\App\Http\Controllers\GalleryController::class, 'saveImage']);
|
Route::post("/g/{url}/save", [\App\Http\Controllers\GalleryController::class, 'saveImage']);
|
||||||
Route::get("/s/watermark", [\App\Http\Controllers\TenantController::class, 'watermarkView']);
|
Route::get("/s/watermark", [\App\Http\Controllers\TenantController::class, 'watermarkView']);
|
||||||
Route::post("/s/watermark", [\App\Http\Controllers\TenantController::class, 'watermarkSave']);
|
Route::post("/s/watermark", [\App\Http\Controllers\TenantController::class, 'watermarkSave']);
|
||||||
|
Route::get("/s/watermark/image", [\App\Http\Controllers\PublicController::class, "returnWatermakeFile"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
Route::get("/{name}", [\App\Http\Controllers\PublicController::class, 'listGalleriesView'])->middleware([\App\Http\Middleware\TenanMiddleware::class]);
|
||||||
|
|
Loading…
Reference in a new issue