Skip to content

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.

Send the image aspect ratio to Bluesky (#526)

Eduardo Bizarro773c8281ec65
diff --git a/app/Services/Social/BlueskyPublisher.php b/app/Services/Social/BlueskyPublisher.php
index ad66d2438..753e04e11 100644
--- a/app/Services/Social/BlueskyPublisher.php
+++ b/app/Services/Social/BlueskyPublisher.php
@@ -193,10 +193,33 @@ class BlueskyPublisher
'images' => $images->map(fn (MediaItem $image): array => [
'alt' => $image->altTextFor(Platform::Bluesky) ?? '',
'image' => $this->uploadBlob($account, $service, $image->url, $image->mime_type) ?? throw $this->mediaUploadFailed(),
+ ...$this->aspectRatio($image),
])->values()->all(),
];
}
+ /**
+ * Without an aspect ratio, Bluesky clients draw the image inside a default
+ * frame and leave empty bands around it.
+ *
+ * @return array{aspectRatio?: array{width: int, height: int}}
+ */
+ private function aspectRatio(MediaItem $image): array
+ {
+ $width = $image->width() ?? 0;
+ $height = $image->height() ?? 0;
+
+ if ($width <= 0) {
+ return [];
+ }
+
+ if ($height <= 0) {
+ return [];
+ }
+
+ return ['aspectRatio' => ['width' => $width, 'height' => $height]];
+ }
+
/**
* The video embed, with its alt text when it has one (an image's `alt` is
* required, a video's optional).
diff --git a/tests/Browser/PublishViewMemoryTest.php b/tests/Browser/PublishViewMemoryTest.php
index f49198302..159e91261 100644
--- a/tests/Browser/PublishViewMemoryTest.php
+++ b/tests/Browser/PublishViewMemoryTest.php
@@ -133,7 +133,7 @@ test('going back to the list keeps the board as the view the user picked', funct
waitFor($page, '@schedule-view-board');
$page->click('@schedule-view-board');
- waitFor($page, '@board-column-draft');
+ waitFor($page, '@board-column-scroll-draft');
$page->back();
waitForPath($page, route('app.posts.index', absolute: false));
diff --git a/tests/Feature/Parity/FullPostParityTest.php b/tests/Feature/Parity/FullPostParityTest.php
index f3acf06f1..6c489dbc8 100644
--- a/tests/Feature/Parity/FullPostParityTest.php
+++ b/tests/Feature/Parity/FullPostParityTest.php
@@ -586,6 +586,10 @@ function fullPostExpected(string $name): array
'mimeType' => 'image/png',
'size' => 1,
],
+ 'aspectRatio' => [
+ 'width' => 1080,
+ 'height' => 1080,
+ ],
],
],
],
@@ -630,6 +634,10 @@ function fullPostExpected(string $name): array
'mimeType' => 'image/png',
'size' => 1,
],
+ 'aspectRatio' => [
+ 'width' => 1080,
+ 'height' => 1080,
+ ],
],
],
],
diff --git a/tests/Feature/Services/Social/BlueskyPublisherTest.php b/tests/Feature/Services/Social/BlueskyPublisherTest.php
index e22870ab7..905f46d64 100644
--- a/tests/Feature/Services/Social/BlueskyPublisherTest.php
+++ b/tests/Feature/Services/Social/BlueskyPublisherTest.php
@@ -455,6 +455,59 @@ test('bluesky publisher includes image alt text in the embed', function () {
});
});
+test('bluesky publisher sends the aspect ratio of every image that has its dimensions', function (array $meta, ?array $expected) {
+ $this->post->update([
+ 'media' => collect([1, 2])->map(fn (int $n): array => [
+ 'id' => "test-media-{$n}",
+ 'path' => "media/2026-01/test-image-{$n}.jpg",
+ 'url' => "https://example.com/media/2026-01/test-image-{$n}.jpg",
+ 'mime_type' => 'image/jpeg',
+ 'original_filename' => "test-{$n}.jpg",
+ 'meta' => $meta,
+ ])->all(),
+ ]);
+
+ $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->post);
+
+ Http::assertSent(function ($request) use ($expected) {
+ if (! str_contains($request->url(), 'createRecord')) {
+ return false;
+ }
+
+ $ratios = collect(data_get($request->data(), 'record.embed.images'))
+ ->map(fn (array $image): ?array => $image['aspectRatio'] ?? null);
+
+ return $ratios->count() === 2 && $ratios->every(fn (?array $ratio): bool => $ratio === $expected);
+ });
+})->with([
+ 'landscape' => [['width' => 1200, 'height' => 630], ['width' => 1200, 'height' => 630]],
+ 'portrait carousel slide' => [['width' => 1080, 'height' => 1350], ['width' => 1080, 'height' => 1350]],
+ 'no dimensions' => [['alt_text' => 'a red bike'], null],
+ 'zero height' => [['width' => 1200, 'height' => 0], null],
+ 'zero width' => [['width' => 0, 'height' => 630], null],
+]);
+
test('bluesky publisher sends empty-string alt when none is set', function () {
$this->post->update([
'media' => [