Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
Publish per-image alt text to Bluesky image embeds
Paulo Castellano555957de6112
diff --git a/app/Services/Social/BlueskyPublisher.php b/app/Services/Social/BlueskyPublisher.phpindex 15d4850da..ae418c3e1 100644--- a/app/Services/Social/BlueskyPublisher.php+++ b/app/Services/Social/BlueskyPublisher.php@@ -4,6 +4,7 @@ declare(strict_types=1);namespace App\Services\Social;+use App\DataTransferObjects\MediaItem;use App\Enums\Media\Type as MediaType;use App\Enums\SocialAccount\Platform;use App\Exceptions\Social\BlueskyPublishException;@@ -63,7 +64,7 @@ class BlueskyPublisher$blob = $this->uploadBlob($account, $service, $media->url, $media->mime_type);if ($blob) {$images[] = [- 'alt' => '',+ 'alt' => $this->altFor($media),'image' => $blob,];}@@ -701,6 +702,21 @@ class BlueskyPublisherreturn "{$webApp}/profile/{$handle}/post/{$postId}";}+ /**+ * Bluesky requires `alt` on every image, so this returns '' (never null)+ * when the user set no description, and the capped description otherwise.+ */+ private function altFor(MediaItem $media): string+ {+ $alt = $media->altText();++ if ($alt === null) {+ return '';+ }++ return mb_substr($alt, 0, Platform::Bluesky->altTextMaxLength());+ }+private function handleApiError(Response $response): never{throw BlueskyPublishException::fromApiResponse($response);diff --git a/tests/Feature/Services/Social/BlueskyPublisherTest.php b/tests/Feature/Services/Social/BlueskyPublisherTest.phpindex 6bd662c65..c5d66e4ef 100644--- a/tests/Feature/Services/Social/BlueskyPublisherTest.php+++ b/tests/Feature/Services/Social/BlueskyPublisherTest.php@@ -403,6 +403,97 @@ test('bluesky publisher attaches an uploaded image as an embed', function () {});});+test('bluesky publisher includes image alt text in the embed', function () {+ $this->post->update([+ 'media' => [+ [+ 'id' => 'test-media-id',+ 'path' => 'media/2026-01/test-image.jpg',+ 'url' => 'https://example.com/media/2026-01/test-image.jpg',+ 'mime_type' => 'image/jpeg',+ 'original_filename' => 'test.jpg',+ 'meta' => ['alt_text' => 'a red bike'],+ ],+ ],+ ]);++ $this->mock(MediaOptimizer::class)+ ->shouldReceive('optimizeImage')+ ->andReturnUsing(fn () => tap(tempnam(sys_get_temp_dir(), 'bsky_test_'), fn ($f) => file_put_contents($f, str_repeat('x', 1024))));++ Http::fake(function ($request) {+ if (str_contains($request->url(), 'uploadBlob')) {+ return Http::response([+ 'blob' => ['$type' => 'blob', 'ref' => ['$link' => 'bafkreiabc123'], 'mimeType' => 'image/jpeg', 'size' => 1024],+ ], 200);+ }++ if (str_contains($request->url(), 'createRecord')) {+ return Http::response([+ 'uri' => 'at://did:plc:testuser123/app.bsky.feed.post/3abc123xyz',+ 'cid' => 'bafyreiabc123',+ ], 200);+ }++ return Http::response(str_repeat('x', 1024), 200); // media download+ });++ $this->publisher->publish($this->postPlatform);++ Http::assertSent(function ($request) {+ if (! str_contains($request->url(), 'createRecord')) {+ return false;+ }++ return data_get($request->data(), 'record.embed.images.0.alt') === 'a red bike';+ });+});++test('bluesky publisher sends empty-string alt when none is set', function () {+ $this->post->update([+ 'media' => [+ [+ 'id' => 'test-media-id',+ 'path' => 'media/2026-01/test-image.jpg',+ 'url' => 'https://example.com/media/2026-01/test-image.jpg',+ 'mime_type' => 'image/jpeg',+ 'original_filename' => 'test.jpg',+ ],+ ],+ ]);++ $this->mock(MediaOptimizer::class)+ ->shouldReceive('optimizeImage')+ ->andReturnUsing(fn () => tap(tempnam(sys_get_temp_dir(), 'bsky_test_'), fn ($f) => file_put_contents($f, str_repeat('x', 1024))));++ Http::fake(function ($request) {+ if (str_contains($request->url(), 'uploadBlob')) {+ return Http::response([+ 'blob' => ['$type' => 'blob', 'ref' => ['$link' => 'bafkreiabc123'], 'mimeType' => 'image/jpeg', 'size' => 1024],+ ], 200);+ }++ if (str_contains($request->url(), 'createRecord')) {+ return Http::response([+ 'uri' => 'at://did:plc:testuser123/app.bsky.feed.post/3abc123xyz',+ 'cid' => 'bafyreiabc123',+ ], 200);+ }++ return Http::response(str_repeat('x', 1024), 200); // media download+ });++ $this->publisher->publish($this->postPlatform);++ Http::assertSent(function ($request) {+ if (! str_contains($request->url(), 'createRecord')) {+ return false;+ }++ return data_get($request->data(), 'record.embed.images.0.alt') === '';+ });+});+test('bluesky publisher refreshes token when expired', function () {$this->socialAccount->update(['token_expires_at' => now()->subHour()]);