Skip to content

Commit

Permalink
better image config
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Aug 23, 2024
1 parent d4255ea commit 29dc474
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ composer require elegantly/laravel-seo
You can publish the config file with:

```bash
php artisan vendor:publish --tag="laravel-seo-config"
php artisan vendor:publish --tag="seo-config"
```

This is the content of the published config file:
Expand Down
8 changes: 5 additions & 3 deletions src/SeoData.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function __construct(
public ?array $schemas = null,
public ?SeoTags $customTags = null,
) {
$this->title = $title ?? config('seo.title') ?? '';
$this->title = $title ?? __(config('seo.title')) ?? '';

Check failure on line 34 in src/SeoData.php

View workflow job for this annotation

GitHub Actions / phpstan

Expression on left side of ?? is not nullable.

Check failure on line 34 in src/SeoData.php

View workflow job for this annotation

GitHub Actions / phpstan

Expression on left side of ?? is not nullable.
$this->canonical = $canonical ?? URL::current();
$this->description = $description ?? config('seo.description');
$this->description = $description ?? __(config('seo.description'));
$this->robots = $robots ?? config('seo.robots');
$this->sitemap = $sitemap ?? config('seo.sitemap');
$this->image = $image ?? $this->getImageFromConfig();
Expand All @@ -43,7 +43,9 @@ public function __construct(
public function getImageFromConfig(): ?Image
{
if ($image = config('seo.image')) {
return new Image($image);
return new Image(
url: filter_var($image, FILTER_VALIDATE_URL) ? $image : asset($image)
);
}

return null;
Expand Down

0 comments on commit 29dc474

Please sign in to comment.