seo image added

This commit is contained in:
HolgerHatGarKeineNode
2023-03-16 18:45:32 +01:00
parent 54d4069658
commit 400c2db26e
8 changed files with 35 additions and 10 deletions

View File

@@ -3,6 +3,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Contracts\Filesystem\Filesystem; use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use League\Glide\Responses\LaravelResponseFactory; use League\Glide\Responses\LaravelResponseFactory;
use League\Glide\ServerFactory; use League\Glide\ServerFactory;
@@ -12,18 +14,24 @@ class ImageController extends Controller
* Handle the incoming request. * Handle the incoming request.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function __invoke(Filesystem $filesystem, $path) public function __invoke(Request $request, Filesystem $filesystem, $path)
{ {
if (str($request->path())->contains('img-public')) {
$filesystemPublic = Storage::disk('publicDisk');
}
$server = ServerFactory::create([ $server = ServerFactory::create([
'response' => new LaravelResponseFactory(app('request')), 'response' => new LaravelResponseFactory(app('request')),
'source' => $filesystem->getDriver(), 'source' => str($request->path())->contains('img-public') ? $filesystemPublic->getDriver() : $filesystem->getDriver(),
'cache' => $filesystem->getDriver(), 'cache' => $filesystem->getDriver(),
'cache_path_prefix' => '.cache', 'cache_path_prefix' => '.cache',
'base_url' => 'img', 'base_url' => $request->route()
->getName() === 'imgPublic' ? '' : 'img',
]); ]);
return $server->getImageResponse('public/'.$path, request()->all()); return $server->getImageResponse($path, request()->all());
} }
} }

View File

@@ -67,7 +67,7 @@ class Welcome extends Component
'SEOData' => new SEOData( 'SEOData' => new SEOData(
title: __('Welcome'), title: __('Welcome'),
description: __('Welcome to the portal of the Einundzwanzig Community.'), description: __('Welcome to the portal of the Einundzwanzig Community.'),
image: asset('img/screenshot.png') image: url()->route('imgPublic', ['path' => 'img/screenshot.png', 'h' => 630, 'w' => 1200, 'fit' => 'crop'])
), ),
]); ]);
} }

View File

@@ -115,7 +115,11 @@ class InternArticleView extends Component
title: $this->libraryItem->name, title: $this->libraryItem->name,
description: strip_tags($this->libraryItem->excerpt) ?? __('Here we post important news that is relevant for everyone.'), description: strip_tags($this->libraryItem->excerpt) ?? __('Here we post important news that is relevant for everyone.'),
author: $this->libraryItem->lecturer->name, author: $this->libraryItem->lecturer->name,
image: $this->libraryItem->getFirstMedia('main') ? $this->libraryItem->getFirstMediaUrl('main') : asset('img/einundzwanzig-wallpaper-benrath.png'), image: $this->libraryItem->getFirstMedia('main')
? $this->libraryItem->getFirstMediaUrl('main', 'seo')
: url()->route('imgPublic', [
'path' => 'img/einundzwanzig-wallpaper-benrath.png', 'h' => 630, 'w' => 1200, 'fit' => 'crop'
]),
published_time: Carbon::parse($this->libraryItem->created_at), published_time: Carbon::parse($this->libraryItem->created_at),
type: 'article', type: 'article',
), ),

View File

@@ -81,6 +81,9 @@ class LibraryItem extends Model implements HasMedia, Sortable, Feedable
->addMediaConversion('preview') ->addMediaConversion('preview')
->fit(Manipulations::FIT_CROP, 300, 300) ->fit(Manipulations::FIT_CROP, 300, 300)
->nonQueued(); ->nonQueued();
$this->addMediaConversion('seo')
->fit(Manipulations::FIT_CROP, 1200, 630)
->nonQueued();
$this->addMediaConversion('thumb') $this->addMediaConversion('thumb')
->fit(Manipulations::FIT_CROP, 130, 130) ->fit(Manipulations::FIT_CROP, 130, 130)
->width(130) ->width(130)

View File

@@ -50,6 +50,12 @@ return [
'throw' => false, 'throw' => false,
], ],
'publicDisk' => [
'driver' => 'local',
'root' => public_path(),
'throw' => false,
],
's3' => [ 's3' => [
'driver' => 's3', 'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'), 'key' => env('AWS_ACCESS_KEY_ID'),

View File

@@ -13,7 +13,7 @@
interessierte Leute und interessante Gesprächspartner. interessierte Leute und interessante Gesprächspartner.
</p> </p>
<p class="text-sm leading-6 text-white">PS: Bitcoin ist begrenzt und daher nicht von Staaten oder Notenbanken <p class="text-sm leading-6 text-white">PS: Bitcoin ist begrenzt und daher nicht von Staaten oder Notenbanken
inflationierbar. Es wird niemals mehr als 21 Millionen Bitcoin geben. Daher auch der Name “Einundzwanzig” inflationierbar. Es wird niemals mehr als 21 Millionen bitcoins geben. Daher auch der Name “Einundzwanzig”
😉 😉
</p> </p>
</div> </div>

View File

@@ -65,7 +65,7 @@
<div class="flex-shrink-0 pt-6"> <div class="flex-shrink-0 pt-6">
<a href="{{ route('article.view', ['libraryItem' => $libraryItem]) }}"> <a href="{{ route('article.view', ['libraryItem' => $libraryItem]) }}">
<img class="h-48 w-full object-contain" <img class="h-48 w-full object-contain"
src="{{ $libraryItem->getFirstMediaUrl('main') }}" src="{{ $libraryItem->getFirstMediaUrl('main', 'seo') }}"
alt="{{ $libraryItem->name }}"> alt="{{ $libraryItem->name }}">
</a> </a>
</div> </div>

View File

@@ -11,6 +11,10 @@ Route::get('/img/{path}', \App\Http\Controllers\ImageController::class)
->where('path', '.*') ->where('path', '.*')
->name('img'); ->name('img');
Route::get('/img-public/{path}', \App\Http\Controllers\ImageController::class)
->where('path', '.*')
->name('imgPublic');
Route::get('auth/auth47', \App\Http\Livewire\Auth\Auth47Component::class) Route::get('auth/auth47', \App\Http\Livewire\Auth\Auth47Component::class)
->name('auth.auth47'); ->name('auth.auth47');