Skip to content

Commit

Permalink
v3.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robdekort committed Oct 26, 2021
1 parent f629754 commit 80746ca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Release Notes

## 3.21.0 (2021-10-26)

### What's new
- Generating social images now works in multisite environments. #157 by @robdekort

## 3.20.0 (2021-10-26)

### What's improved
Expand Down
6 changes: 3 additions & 3 deletions app/Jobs/GenerateSocialImagesJob.php
Expand Up @@ -53,20 +53,20 @@ public function handle()
// Prepare.
$id = $item->id();
$title = Str::of($item->get('title'))->slug('-');
$app_url = config('app.url');
$absolute_url = $item->site()->absoluteUrl();
$unique = time();

// Generate, save and set default og image.
$file = "{$title}-og-{$unique}.png";
$image = Browsershot::url("{$app_url}/social-images/{$id}")
$image = Browsershot::url("{$absolute_url}/social-images/{$id}")
->windowSize(1200, 630)
->select('#og')
->save($disk->path($file));
$item->set('og_image', $file)->save();

// Generate, save and set default twitter image.
$file = "{$title}-twitter-{$unique}.png";
$image = Browsershot::url("{$app_url}/social-images/{$id}")
$image = Browsershot::url("{$absolute_url}/social-images/{$id}")
->windowSize(1200, 600)
->select('#twitter')
->save($disk->path($file));
Expand Down
2 changes: 1 addition & 1 deletion dev/CHANGELOG.md
@@ -1,6 +1,6 @@
# Release Notes

## Unreleased
## 3.21.0 (2021-10-26)

### What's new
- Generating social images now works in multisite environments. #157 by @robdekort
Expand Down
9 changes: 6 additions & 3 deletions routes/web.php
Expand Up @@ -2,6 +2,7 @@

use App\Http\Controllers\DynamicToken;
use Illuminate\Support\Facades\Route;
use Statamic\Facades\Site;

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -29,9 +30,11 @@
]);

// The Social Image route to generate social images.
// Route::statamic('/social-images/{id}', 'social_images', [
// 'layout' => null
// ]);
Site::all()->each(function ($site) {
Route::statamic("{$site->url()}/social-images/{id}", 'social_images', [
'layout' => null,
]);
});

// The Search route to display search results with `views/search.antlers.html`.
// Route::statamic('/search', 'search', [
Expand Down

0 comments on commit 80746ca

Please sign in to comment.