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.

Let videos take alt text on Mastodon, Bluesky, Threads and Discord (#511)

Paulo Castellanoada819b4bc04
diff --git a/AGENTS.md b/AGENTS.md
index aab9dcb12..e8195fd83 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -208,6 +208,15 @@ Vue components must have a single root element.
A function that decides between several outcomes is a list of early returns, one case per `if`, read from top to bottom (owner decision November 2026). Never a ternary inside a ternary, a ternary inside an `if`, or a ternary whose condition joins several checks with `||` / `&&`.
- One ternary with a single plain condition is fine (`filled($channel) ? 'channel' : 'all'`). Anything more becomes `if` blocks with braces.
+- A ternary that picks between two arrays, or that does not fit on one line, is an `if` too, even with a single plain condition (owner decision November 2026). Put the choice in a small method with an early return, so each case reads on its own (`ThreadsPublisher::mediaSource()` is the reference):
+
+ ```php
+ if ($media->isVideo()) {
+ return ['media_type' => 'VIDEO', 'video_url' => $media->url];
+ }
+
+ return ['media_type' => 'IMAGE', 'image_url' => $media->url];
+ ```
- Name a check used twice (`const imported = post.origin === PostOrigin.Network`) instead of repeating it in each branch.
- When the outcome follows from what the user clicked, let each action say it (`publishNow()` toasts "publishing") instead of guessing it back from the payload.
- A `match` lists every case it accepts and has no `default` that hides an unknown value; an unknown value should fail, not read as another case.
diff --git a/app/Actions/Post/HostInlineMedia.php b/app/Actions/Post/HostInlineMedia.php
index a2fa79263..f42761a0c 100644
--- a/app/Actions/Post/HostInlineMedia.php
+++ b/app/Actions/Post/HostInlineMedia.php
@@ -116,8 +116,8 @@ class HostInlineMedia
/**
* The row as the composer shape the save validates, with the client's
* editable meta (alt text, user tags, cover offset and source) on top of
- * what is stored. The `alt` shorthand only applies to images, and never
- * over an `alt_text` sent in `meta`.
+ * what is stored. The `alt` shorthand applies to images and videos (a PDF
+ * has no alt text), and never over an `alt_text` sent in `meta`.
*
* @param array<string, mixed> $reference
* @return array<string, mixed>
@@ -340,7 +340,7 @@ class HostInlineMedia
{
$alt = data_get($reference, 'alt');
- if ($row->type !== MediaType::Image) {
+ if ($row->type === MediaType::Document) {
return $edits;
}
diff --git a/app/Dto/MediaItem.php b/app/Dto/MediaItem.php
index 9fc0023ec..b16d1cece 100644
--- a/app/Dto/MediaItem.php
+++ b/app/Dto/MediaItem.php
@@ -136,7 +136,7 @@ class MediaItem
}
/**
- * User-provided accessibility description for this image, when set.
+ * User-provided accessibility description for this image or video, when set.
*/
public function altText(): ?string
{
diff --git a/app/Enums/PostPlatform/ContentType.php b/app/Enums/PostPlatform/ContentType.php
index 816db8f24..9d162e77b 100644
--- a/app/Enums/PostPlatform/ContentType.php
+++ b/app/Enums/PostPlatform/ContentType.php
@@ -509,9 +509,17 @@ enum ContentType: string
/**
* Whether the editor offers the Alt Text tab for images of this type.
*/
- public function supportsAltText(): bool
+ public function supportsImageAltText(): bool
{
- return $this->supportsImage() && $this->platform()->supportsAltText();
+ return $this->supportsImage() && $this->platform()->supportsImageAltText();
+ }
+
+ /**
+ * Whether the editor offers the Alt Text tab for videos of this type.
+ */
+ public function supportsVideoAltText(): bool
+ {
+ return $this->supportsVideo() && $this->platform()->supportsVideoAltText();
}
/**
@@ -573,6 +581,7 @@ enum ContentType: string
* auto_fits_image: bool,
* crop_presets: list<string>,
* supports_alt_text: bool,
+ * supports_video_alt_text: bool,
* supports_user_tags: bool,
* supports_video_cover: bool,
* supports_custom_video_cover: bool,
@@ -610,7 +619,8 @@ enum ContentType: string
'video_aspect_ratio_max' => $videoBounds['max'] ?? null,
'auto_fits_image' => $this->autoFitsImage(),
'crop_presets' => $this->cropPresets(),
- 'supports_alt_text' => $this->supportsAltText(),
+ 'supports_alt_text' => $this->supportsImageAltText(),
+ 'supports_video_alt_text' => $this->supportsVideoAltText(),
'supports_user_tags' => $this->supportsUserTags(),
'supports_video_cover' => $this->supportsVideoCover(),
'supports_custom_video_cover' => $this->supportsCustomVideoCover(),
@@ -653,6 +663,7 @@ enum ContentType: string
* image_max_width: int|null,
* image_max_height: int|null,
* supports_alt_text: bool,
+ * supports_video_alt_text: bool,
* supports_user_tags: bool,
* supports_video_cover: bool,
* supports_custom_video_cover: bool,
@@ -694,6 +705,7 @@ enum ContentType: string
'image_max_width',
'image_max_height',
'supports_alt_text',
+ 'supports_video_alt_text',
'supports_user_tags',
'supports_video_cover',
'supports_custom_video_cover',
diff --git a/app/Enums/SocialAccount/Platform.php b/app/Enums/SocialAccount/Platform.php
index 43ffe11a9..13d91760a 100644
--- a/app/Enums/SocialAccount/Platform.php
+++ b/app/Enums/SocialAccount/Platform.php
@@ -200,11 +200,22 @@ enum Platform: string
* Whether the platform's API accepts image alt text (accessibility
* description) on published media.
*/
- public function supportsAltText(): bool
+ public function supportsImageAltText(): bool
{
return $this->altTextMaxLength() !== null;
}
+ /**
+ * Whether the platform's API also takes alt text on a video: Bluesky
+ * (`alt` on `app.bsky.embed.video`), Mastodon (`description` on the media
+ * upload), Threads (`alt_text` on a video container) and Discord
+ * (`description` on the attachment).
+ */
+ public function supportsVideoAltText(): bool
+ {
+ return in_array($this, [self::Bluesky, self::Mastodon, self::Threads, self::Discord], true);
+ }
+
/**
* Hard cap (in characters) the platform's API will accept. Going over this
* means the post can't be published. Values are the documented API maxes:
diff --git a/app/Mcp/Concerns/DescribesPostMedia.php b/app/Mcp/Concerns/DescribesPostMedia.php
index e3ae66227..fa8b9a8af 100644
--- a/app/Mcp/Concerns/DescribesPostMedia.php
+++ b/app/Mcp/Concerns/DescribesPostMedia.php
@@ -20,8 +20,8 @@ trait DescribesPostMedia
'upload_token' => $item->string()->description('Token of a file uploaded earlier with request-media-upload-tool; valid once, before it expires. To use the same file on another post, pass the media id the first post returned.'),
'url' => $item->string()->description('Public http(s) URL that serves the file itself (a JPEG, PNG, GIF or WebP image, HEIC or HEIF when the server can convert it, an MP4 or MOV video, or a PDF; redirects are not followed and web pages are refused); downloaded once per call, within 20 seconds, up to the server limits (by default 10 MB and 67 megapixels for an image, 1 GB for a video, 100 MB for a PDF).'),
'id' => $item->string()->description('UUID of a media item of this workspace, as returned in a post\'s media (get-post-tool, list-posts-tool); copied for the post. An id already on the post keeps it, so send the current ids in the new order to reorder, and leave one out to remove it.'),
- 'alt' => $item->string()->description('Alt text for an image (ignored for video and PDF).'),
- 'meta' => $item->object()->description('Per-item settings: alt_text (string, up to 2000 characters; cut to the network limit, alt_text_max_length in list-content-types-tool, when published), user_tags (Instagram feed images only: up to 20 of {username, x, y}, x and y between 0 and 1 from the top-left corner), cover_offset_ms (video cover frame in milliseconds, for content types with supports_video_cover), cover (an image used as the video cover instead of a frame, for content types with supports_custom_video_cover: {upload_token}, {url} or {id} like a media item; a still image; the network crops it to the middle 9:16, so upload it at 9:16. YouTube applies it once the video is processed, and a channel that is not verified cannot take one), cover_source (frame or image: where the cover comes from, image when cover is sent without it; with frame, cover_offset_ms is the cover, and YouTube, which takes no frame time, uses cover as that frame\'s screenshot; a network that only takes a frame keeps cover_offset_ms and drops cover).'),
+ 'alt' => $item->string()->description('Alt text for an image or a video (ignored for PDF; sent for a video only where supports_video_alt_text).'),
+ 'meta' => $item->object()->description('Per-item settings: alt_text (string, up to 2000 characters; cut to the network limit, alt_text_max_length in list-content-types-tool, when published; sent for images where supports_alt_text, and for videos where supports_video_alt_text), user_tags (Instagram feed images only: up to 20 of {username, x, y}, x and y between 0 and 1 from the top-left corner), cover_offset_ms (video cover frame in milliseconds, for content types with supports_video_cover), cover (an image used as the video cover instead of a frame, for content types with supports_custom_video_cover: {upload_token}, {url} or {id} like a media item; a still image; the network crops it to the middle 9:16, so upload it at 9:16. YouTube applies it once the video is processed, and a channel that is not verified cannot take one), cover_source (frame or image: where the cover comes from, image when cover is sent without it; with frame, cover_offset_ms is the cover, and YouTube, which takes no frame time, uses cover as that frame\'s screenshot; a network that only takes a frame keeps cover_offset_ms and drops cover).'),
]))
->description("{$description} Items keep the order given (the first is the cover of a carousel). Each item gives exactly one of upload_token, url or id. A PDF must be the only attachment. Check the content type's media rules with list-content-types-tool.");
}
diff --git a/app/Mcp/Tools/Platform/ListContentTypesTool.php b/app/Mcp/Tools/Platform/ListContentTypesTool.php
index 5ddb350a6..9a301640c 100644
--- a/app/Mcp/Tools/Platform/ListContentTypesTool.php
+++ b/app/Mcp/Tools/Platform/ListContentTypesTool.php
@@ -20,7 +20,7 @@ use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly(true)]
#[IsDestructive(false)]
#[IsOpenWorld(false)]
-#[Description('List every platform with its content types and their rules. Per content type: max/min media count, requires_media, accept_images/accept_videos/accept_documents, accepts_gif, accepts_mov, forbids_mixed_media, max_video_duration_sec (null = no cap), max_image_bytes / max_video_bytes / max_document_bytes, aspect_ratio_min / aspect_ratio_max for images and video_aspect_ratio_min / video_aspect_ratio_max for videos (width / height, null = not checked; GIFs are never checked; auto_fits_image when images are fitted into the frame on publish instead), image_min_width / image_min_height / image_max_width / image_max_height in pixels, supports_alt_text, supports_user_tags (Instagram tags in media meta.user_tags), supports_video_cover (meta.cover_offset_ms), supports_custom_video_cover (an image as the video cover, media meta.cover; Instagram Reels and YouTube Shorts), captionless (stories publish no text, so the text is neither sent nor measured), document_must_be_alone (a PDF must be the only attachment), supports_thread_replies and max_thread_replies (meta.thread_replies: a thread on X, Bluesky or Mastodon, or one comment on LinkedIn). Per platform: allowed_media_types, default_content_type, max_content_length (the default text limit of the network; the limit of each account, such as 25000 for an X account with long posts, is max_content_length in list-social-accounts-tool), max_hashtags (Instagram: 5), alt_text_max_length and required_meta (meta every post of the platform needs before it is scheduled or published; some needs depend on the content type and are not listed: Google Business events and offers also need meta.event, a YouTube post needs meta.title or text, and an X poll (x_poll) needs meta.poll with at least 2 options and duration_minutes, plus text as its question). Media rules never block a draft: they are checked when a post is scheduled, queued or published (create-post-tool, create-posts-tool, update-post-tool, publish-post-tool), and a post whose media breaks a rule of its content_type is rejected with a per-platform error. The exception is an X poll (content_type x_poll, or a reply in meta.thread_replies with a poll): media, a repeated choice, more than 4 choices, a choice over 25 characters or a duration_minutes outside 5–10080 is refused on every save, drafts included, and the attach media tools refuse it too. Call this before attaching media or choosing a content_type.')]
+#[Description('List every platform with its content types and their rules. Per content type: max/min media count, requires_media, accept_images/accept_videos/accept_documents, accepts_gif, accepts_mov, forbids_mixed_media, max_video_duration_sec (null = no cap), max_image_bytes / max_video_bytes / max_document_bytes, aspect_ratio_min / aspect_ratio_max for images and video_aspect_ratio_min / video_aspect_ratio_max for videos (width / height, null = not checked; GIFs are never checked; auto_fits_image when images are fitted into the frame on publish instead), image_min_width / image_min_height / image_max_width / image_max_height in pixels, supports_alt_text (alt_text on images), supports_video_alt_text (alt_text on videos too: Mastodon, Bluesky, Threads and Discord), supports_user_tags (Instagram tags in media meta.user_tags), supports_video_cover (meta.cover_offset_ms), supports_custom_video_cover (an image as the video cover, media meta.cover; Instagram Reels and YouTube Shorts), captionless (stories publish no text, so the text is neither sent nor measured), document_must_be_alone (a PDF must be the only attachment), supports_thread_replies and max_thread_replies (meta.thread_replies: a thread on X, Bluesky or Mastodon, or one comment on LinkedIn). Per platform: allowed_media_types, default_content_type, max_content_length (the default text limit of the network; the limit of each account, such as 25000 for an X account with long posts, is max_content_length in list-social-accounts-tool), max_hashtags (Instagram: 5), alt_text_max_length and required_meta (meta every post of the platform needs before it is scheduled or published; some needs depend on the content type and are not listed: Google Business events and offers also need meta.event, a YouTube post needs meta.title or text, and an X poll (x_poll) needs meta.poll with at least 2 options and duration_minutes, plus text as its question). Media rules never block a draft: they are checked when a post is scheduled, queued or published (create-post-tool, create-posts-tool, update-post-tool, publish-post-tool), and a post whose media breaks a rule of its content_type is rejected with a per-platform error. The exception is an X poll (content_type x_poll, or a reply in meta.thread_replies with a poll): media, a repeated choice, more than 4 choices, a choice over 25 characters or a duration_minutes outside 5–10080 is refused on every save, drafts included, and the attach media tools refuse it too. Call this before attaching media or choosing a content_type.')]
class ListContentTypesTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php b/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
index 365d0abb7..ee47072ac 100644
--- a/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
+++ b/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
@@ -81,7 +81,7 @@ class AttachMediaFromUploadTool extends Tool
return [
'post_id' => $schema->string()->required()->description('UUID of the post to attach the uploaded media to.'),
'upload_token' => $schema->string()->required()->description('upload_token returned by request-media-upload-tool, after the file was sent to its upload_url.'),
- 'alt' => $schema->string()->description('Optional accessibility alt text for the media (applies to images).'),
+ 'alt' => $schema->string()->description('Optional accessibility alt text for an image or a video (ignored for PDF; sent for a video only where supports_video_alt_text).'),
'meta' => $schema->object()->description('Optional per-item settings: user_tags (Instagram feed images only: up to 20 of {username, x, y}, x and y between 0 and 1 from the top-left corner), cover_offset_ms (video cover frame in milliseconds, for content types with supports_video_cover).'),
];
}
diff --git a/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php b/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php
index fd4200d64..110229817 100644
--- a/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php
+++ b/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php
@@ -74,7 +74,7 @@ class AttachMediaFromUrlTool extends Tool
'urls' => $schema->array()
->items($schema->object(fn ($u) => [
'url' => $u->string()->required()->description('Public HTTP/HTTPS URL of an image, video, or PDF.'),
- 'alt' => $u->string()->description('Optional accessibility alt text for the image (ignored for video/PDF, which have no alt text).'),
+ 'alt' => $u->string()->description('Optional accessibility alt text for an image or a video (ignored for PDF; sent for a video only where supports_video_alt_text).'),
'meta' => $u->object()->description('Optional per-item settings: user_tags (Instagram feed images only: up to 20 of {username, x, y}, x and y between 0 and 1 from the top-left corner), cover_offset_ms (video cover frame in milliseconds, for content types with supports_video_cover).'),
]))
->required()
diff --git a/app/Services/Social/BlueskyPublisher.php b/app/Services/Social/BlueskyPublisher.php
index efc9f54f5..ad66d2438 100644
--- a/app/Services/Social/BlueskyPublisher.php
+++ b/app/Services/Social/BlueskyPublisher.php
@@ -167,46 +167,64 @@ class BlueskyPublisher
*/
private function mediaEmbed(SocialAccount $account, string $service, Collection $medias): ?array
{
- $images = [];
-
- foreach ($medias->take(4) as $media) {
- if ($media->isImage()) {
- $blob = $this->uploadBlob($account, $service, $media->url, $media->mime_type);
- if (! $blob) {
- throw new BlueskyPublishException(
- userMessage: 'Media upload to Bluesky failed. Please try again.',
- category: ErrorCategory::ServerError,
- );
- }
-
- $images[] = [
- 'alt' => $media->altTextFor(Platform::Bluesky) ?? '',
- 'image' => $blob,
- ];
- }
- }
+ $images = $medias->take(4)->filter(fn (MediaItem $media): bool => $media->isImage());
- if ($images !== []) {
- return [
- '$type' => BlueskyLexicon::EMBED_IMAGES,
- 'images' => $images,
- ];
+ if ($images->isNotEmpty()) {
+ return $this->imagesEmbed($account, $service, $images);
}
$video = $medias->first(fn (MediaItem $media): bool => $media->isVideo());
- $videoBlob = $video ? $this->uploadVideo($account, $service, $video->url, $video->mime_type) : null;
- if ($video && ! $videoBlob) {
- throw new BlueskyPublishException(
- userMessage: 'Media upload to Bluesky failed. Please try again.',
- category: ErrorCategory::ServerError,
- );
+ if (blank($video)) {
+ return null;
}
- return $videoBlob ? [
+ return $this->videoEmbed($account, $service, $video);
+ }
+
+ /**
+ * @param Collection<int, MediaItem> $images
+ * @return array<string, mixed>
+ */
+ private function imagesEmbed(SocialAccount $account, string $service, Collection $images): array
+ {
+ return [
+ '$type' => BlueskyLexicon::EMBED_IMAGES,
+ '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(),
+ ])->values()->all(),
+ ];
+ }
+
+ /**
+ * The video embed, with its alt text when it has one (an image's `alt` is
+ * required, a video's optional).
+ *
+ * @return array<string, mixed>
+ */
+ private function videoEmbed(SocialAccount $account, string $service, MediaItem $video): array
+ {
+ $embed = [
'$type' => BlueskyLexicon::EMBED_VIDEO,
- 'video' => $videoBlob,
- ] : null;
+ 'video' => $this->uploadVideo($account, $service, $video->url, $video->mime_type) ?? throw $this->mediaUploadFailed(),
+ ];
+
+ $alt = $video->altTextFor(Platform::Bluesky);
+
+ if (blank($alt)) {
+ return $embed;
+ }
+
+ return [...$embed, 'alt' => $alt];
+ }
+
+ private function mediaUploadFailed(): BlueskyPublishException
+ {
+ return new BlueskyPublishException(
+ userMessage: 'Media upload to Bluesky failed. Please try again.',
+ category: ErrorCategory::ServerError,
+ );
}
/**
diff --git a/app/Services/Social/Discord/DiscordPublisher.php b/app/Services/Social/Discord/DiscordPublisher.php
index 2c2dd12be..ce6c5b60f 100644
--- a/app/Services/Social/Discord/DiscordPublisher.php
+++ b/app/Services/Social/Discord/DiscordPublisher.php
@@ -127,7 +127,7 @@ class DiscordPublisher
$attachment = ['id' => $index, 'filename' => $filename];
- $alt = $item->isImage() ? $item->altTextFor(Platform::Discord) : null;
+ $alt = $item->altTextFor(Platform::Discord);
if ($alt !== null) {
$attachment['description'] = $alt;
diff --git a/app/Services/Social/MastodonPublisher.php b/app/Services/Social/MastodonPublisher.php
index 8d0cc9da3..95e053117 100644
--- a/app/Services/Social/MastodonPublisher.php
+++ b/app/Services/Social/MastodonPublisher.php
@@ -83,7 +83,7 @@ class MastodonPublisher
$mediaIds = [];
foreach ($media->take(4) as $item) {
- $mediaIds[] = $this->uploadMedia($account, $instance, $item->url, $item->original_filename, $item->isImage() ? $item->altTextFor(Platform::Mastodon) : null);
+ $mediaIds[] = $this->uploadMedia($account, $instance, $item->url, $item->original_filename, $item->altTextFor(Platform::Mastodon));
}
return $mediaIds === [] ? [] : ['media_ids' => $mediaIds];
diff --git a/app/Services/Social/ThreadsPublisher.php b/app/Services/Social/ThreadsPublisher.php
index c650ae398..70a41c990 100644
--- a/app/Services/Social/ThreadsPublisher.php
+++ b/app/Services/Social/ThreadsPublisher.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Services\Social;
+use App\Dto\MediaItem;
use App\Enums\PostPlatform\ContentType;
use App\Enums\SocialAccount\Platform;
use App\Exceptions\Social\ErrorCategory;
@@ -83,19 +84,9 @@ class ThreadsPublisher
);
}
- $firstMedia = $media->first();
- $isVideo = $firstMedia->isVideo();
-
- // Single media
if ($media->count() === 1) {
- if ($isVideo) {
- return $this->publishMediaWithRetry(
- fn (): array => $this->publishVideoPost($userId, $accessToken, $content, $firstMedia),
- );
- }
-
return $this->publishMediaWithRetry(
- fn (): array => $this->publishImagePost($userId, $accessToken, $content, $firstMedia),
+ fn (): array => $this->publishSingleMedia($userId, $accessToken, $content, $media->first()),
);
}
@@ -137,27 +128,19 @@ class ThreadsPublisher
return $this->publishContainer($userId, $accessToken, $containerId);
}
- private function publishImagePost(string $userId, string $accessToken, ?string $content, $media): array
+ private function publishSingleMedia(string $userId, string $accessToken, ?string $content, MediaItem $media): array
{
- // Step 1: Create container
- $params = [
- 'media_type' => 'IMAGE',
- 'image_url' => $media->url,
+ $kind = $media->isVideo() ? 'video' : 'image';
+
+ $containerResponse = $this->socialHttp()->post("{$this->baseUrl}/{$userId}/threads", [
+ ...$this->mediaParams($media),
'text' => $content,
...$this->containerOptions,
'access_token' => $accessToken,
- ];
-
- $alt = $media->altTextFor(Platform::Threads);
-
- if ($alt !== null) {
- $params['alt_text'] = $alt;
- }
-
- $containerResponse = $this->socialHttp()->post("{$this->baseUrl}/{$userId}/threads", $params);
+ ]);
if ($containerResponse->failed()) {
- Log::error('Threads image container creation failed', [
+ Log::error("Threads {$kind} container creation failed", [
'status' => $containerResponse->status(),
'body' => $this->redactResponseBody($containerResponse->body()),
]);
@@ -168,51 +151,44 @@ class ThreadsPublisher
if (! $containerId) {
throw new ThreadsPublishException(
- userMessage: 'Threads did not accept the image. Please try again.',
+ userMessage: "Threads did not accept the {$kind}. Please try again.",
category: ErrorCategory::ServerError,
);
}
- // Step 2: Wait for image processing
$this->waitForMediaProcessing($containerId, $accessToken);
- // Step 3: Publish
return $this->publishContainer($userId, $accessToken, $containerId);
}
- private function publishVideoPost(string $userId, string $accessToken, ?string $content, $media): array
+ /**
+ * The container fields of one image or video: its type, its URL and its
+ * alt text, which Threads takes on both.
+ *
+ * @return array<string, string>
+ */
+ private function mediaParams(MediaItem $media): array
{
- // Step 1: Create container
- $containerResponse = $this->socialHttp()->post("{$this->baseUrl}/{$userId}/threads", [
- 'media_type' => 'VIDEO',
- 'video_url' => $media->url,
- 'text' => $content,
- ...$this->containerOptions,
- 'access_token' => $accessToken,
- ]);
+ $params = $this->mediaSource($media);
+ $alt = $media->altTextFor(Platform::Threads);
- if ($containerResponse->failed()) {
- Log::error('Threads video container creation failed', [
- 'status' => $containerResponse->status(),
- 'body' => $this->redactResponseBody($containerResponse->body()),
- ]);
- $this->handleApiError($containerResponse);
+ if (blank($alt)) {
+ return $params;
}
- $containerId = $containerResponse->json()['id'] ?? null;
+ return [...$params, 'alt_text' => $alt];
+ }
- if (! $containerId) {
- throw new ThreadsPublishException(
- userMessage: 'Threads did not accept the video. Please try again.',
- category: ErrorCategory::ServerError,
- );
+ /**
+ * @return array{media_type: string, video_url?: string, image_url?: string}
+ */
+ private function mediaSource(MediaItem $media): array
+ {
+ if ($media->isVideo()) {
+ return ['media_type' => 'VIDEO', 'video_url' => $media->url];
}
- // Wait for video processing
- $this->waitForMediaProcessing($containerId, $accessToken);
-
- // Step 2: Publish
- return $this->publishContainer($userId, $accessToken, $containerId);
+ return ['media_type' => 'IMAGE', 'image_url' => $media->url];
}
private function publishCarousel(string $userId, string $accessToken, ?string $content, $mediaCollection): array
@@ -221,28 +197,11 @@ class ThreadsPublisher
$childContainers = [];
foreach ($mediaCollection as $media) {
- $isVideo = $media->isVideo();
-
- $params = [
+ $containerResponse = $this->socialHttp()->post("{$this->baseUrl}/{$userId}/threads", [
+ ...$this->mediaParams($media),
'is_carousel_item' => 'true',
'access_token' => $accessToken,
- ];
-
- if ($isVideo) {
- $params['media_type'] = 'VIDEO';
- $params['video_url'] = $media->url;
- } else {
- $params['media_type'] = 'IMAGE';
- $params['image_url'] = $media->url;
-
- $alt = $media->altTextFor(Platform::Threads);
-
- if ($alt !== null) {
- $params['alt_text'] = $alt;
- }
- }
-
- $containerResponse = $this->socialHttp()->post("{$this->baseUrl}/{$userId}/threads", $params);
+ ]);
if ($containerResponse->failed()) {
Log::error('Threads carousel item creation failed', [
diff --git a/resources/js/components/posts/composer/MediaEditorAltTextPanel.vue b/resources/js/components/posts/composer/MediaEditorAltTextPanel.vue
index 5149b0804..5693cfc53 100644
--- a/resources/js/components/posts/composer/MediaEditorAltTextPanel.vue
+++ b/resources/js/components/posts/composer/MediaEditorAltTextPanel.vue
@@ -11,6 +11,8 @@ import { altText as generateAltTextRoute } from '@/routes/app/posts/ai';
const props = defineProps<{
mediaId: string;
+ /** Whether the AI can write the alt text: images only, never a video. */
+ generates: boolean;
}>();
const edit = defineModel<MediaEdit>('edit', { required: true });
@@ -61,6 +63,7 @@ const generate = async (): Promise<void> => {
:placeholder="$t('posts.composer.media_editor.alt_placeholder')"
/>
<Button
+ v-if="generates"
type="button"
variant="outline"
class="w-full"
diff --git a/resources/js/components/posts/composer/MediaEditorDialog.vue b/resources/js/components/posts/composer/MediaEditorDialog.vue
index 633a82b98..47b787664 100644
--- a/resources/js/components/posts/composer/MediaEditorDialog.vue
+++ b/resources/js/components/posts/composer/MediaEditorDialog.vue
@@ -129,6 +129,8 @@ const activeItem = computed(() => editingItems.value[activeIndex.value]);
const activeIsVideo = computed(() =>
activeItem.value ? isVideo(activeItem.value) : false,
);
+/** The AI writes alt text for images only. */
+const generatesAltText = computed(() => !activeIsVideo.value);
const stageVideoEl = ref<HTMLVideoElement | null>(null);
const stageVideoDurations = ref<Record<number, number>>({});
@@ -871,6 +873,7 @@ watch(tagging, (isTagging) => {
v-else-if="tab === 'alt' && edit"
v-model:edit="edit"
:media-id="activeItem.id"
+ :generates="generatesAltText"
/>
<MediaEditorTagsPanel
v-else-if="tab === 'tags' && edit"
diff --git a/resources/js/composables/useMediaRules.ts b/resources/js/composables/useMediaRules.ts
index dbb546dfe..d0efb75c6 100644
--- a/resources/js/composables/useMediaRules.ts
+++ b/resources/js/composables/useMediaRules.ts
@@ -22,7 +22,8 @@ const DEFAULT_RULES: MediaRules = {
acceptsGif: false,
acceptsMov: true,
cropPresets: [],
- supportsAltText: false,
+ supportsImageAltText: false,
+ supportsVideoAltText: false,
supportsUserTags: false,
supportsVideoCover: false,
supportsCustomVideoCover: false,
diff --git a/resources/js/lib/contentTypeMediaRules.ts b/resources/js/lib/contentTypeMediaRules.ts
index 19d0890ac..fc9448ecc 100644
--- a/resources/js/lib/contentTypeMediaRules.ts
+++ b/resources/js/lib/contentTypeMediaRules.ts
@@ -23,7 +23,8 @@ export type MediaRules = {
videoAspectRatioMax?: number;
autoFitsImage?: boolean;
cropPresets: CropPresetValue[];
- supportsAltText: boolean;
+ supportsImageAltText: boolean;
+ supportsVideoAltText: boolean;
supportsUserTags: boolean;
supportsVideoCover: boolean;
supportsCustomVideoCover: boolean;
@@ -58,6 +59,7 @@ export type ContentTypeMediaRule = {
auto_fits_image: boolean;
crop_presets: CropPresetValue[];
supports_alt_text: boolean;
+ supports_video_alt_text: boolean;
supports_user_tags: boolean;
supports_video_cover: boolean;
supports_custom_video_cover: boolean;
@@ -114,7 +116,8 @@ export const toMediaRules = (rule: ContentTypeMediaRule): MediaRules => ({
videoAspectRatioMax: rule.video_aspect_ratio_max ?? undefined,
autoFitsImage: rule.auto_fits_image,
cropPresets: rule.crop_presets,
- supportsAltText: rule.supports_alt_text,
+ supportsImageAltText: rule.supports_alt_text,
+ supportsVideoAltText: rule.supports_video_alt_text,
supportsUserTags: rule.supports_user_tags,
supportsVideoCover: rule.supports_video_cover,
supportsCustomVideoCover: rule.supports_custom_video_cover,
diff --git a/resources/js/lib/mediaEditor.ts b/resources/js/lib/mediaEditor.ts
index 446d98345..7f9c02669 100644
--- a/resources/js/lib/mediaEditor.ts
+++ b/resources/js/lib/mediaEditor.ts
@@ -146,28 +146,46 @@ const hasThumbnail = (rule: MediaRules): boolean => {
return rule.supportsCustomVideoCover;
};
+/** A tab and the rule that offers it. */
+type OptionalTab = {
+ tab: EditorTab;
+ offeredBy: (rule: MediaRules) => boolean;
+};
+
+const VIDEO_TABS: OptionalTab[] = [
+ { tab: 'thumbnail', offeredBy: hasThumbnail },
+ { tab: 'alt', offeredBy: (rule) => rule.supportsVideoAltText },
+];
+
+const IMAGE_TABS: OptionalTab[] = [
+ { tab: 'alt', offeredBy: (rule) => rule.supportsImageAltText },
+ { tab: 'tags', offeredBy: (rule) => rule.supportsUserTags },
+];
+
+/** The tabs a network of the post offers, in order. */
+const offeredTabs = (tabs: OptionalTab[], rules: MediaRules[]): EditorTab[] =>
+ tabs
+ .filter(({ offeredBy }) => rules.some(offeredBy))
+ .map(({ tab }) => tab);
+
/** Tabs the editor offers for an item; an empty list means no pencil. */
export const editorTabsFor = (
item: MediaItem,
rules: MediaRules[],
): EditorTab[] => {
if (isVideo(item)) {
- return rules.some(hasThumbnail) ? ['thumbnail'] : [];
+ return offeredTabs(VIDEO_TABS, rules);
+ }
+
+ if (!isImage(item)) {
+ return [];
}
- if (!isImage(item) || isGif(item)) {
+ if (isGif(item)) {
return [];
}
- return [
- 'edit',
- ...(rules.some((rule) => rule.supportsAltText)
- ? (['alt'] as const)
- : []),
- ...(rules.some((rule) => rule.supportsUserTags)
- ? (['tags'] as const)
- : []),
- ];
+ return ['edit', ...offeredTabs(IMAGE_TABS, rules)];
};
/** An untouched edit: no crop, turn, flip, filter or metadata. */
diff --git a/tests/Browser/MediaEditorTest.php b/tests/Browser/MediaEditorTest.php
index d141b5e48..3307d44a1 100644
--- a/tests/Browser/MediaEditorTest.php
+++ b/tests/Browser/MediaEditorTest.php
@@ -792,6 +792,35 @@ test('a reel video gets a Thumbnail segment whose frame is saved as the cover of
$page->assertNoJavaScriptErrors();
});
+test('a video takes alt text, written by hand, where its network accepts it', function (ContentType $contentType) {
+ [$post] = seedMediaEditorVideoPost($contentType);
+ $post->update(['media' => [[...$post->media[0], 'meta' => [...$post->media[0]['meta'], 'cover_offset_ms' => 1500]]]]);
+ $accountId = $post->social_account_id;
+ $page = visit(route('app.posts.edit', $post));
+ waitFor($page, "@composer-{$accountId}-alt-0");
+ $page->assertMissing("@composer-{$accountId}-edit-0")
+ ->click("@composer-{$accountId}-alt-0");
+ waitFor($page, '@media-editor-alt-text');
+
+ $page->assertVisible('@media-editor-stage-video')
+ ->assertMissing('@media-editor-alt-generate');
+
+ $page->type('@media-editor-alt-text', 'A cyclist crossing a bridge at sunset');
+ waitForState($page, '@media-editor-apply', 'element.disabled === false');
+ $page->click('@media-editor-apply');
+ saveMediaEditorDraft($page);
+
+ expect(data_get($post->fresh()->media, '0.meta.alt_text'))->toBe('A cyclist crossing a bridge at sunset')
+ ->and(data_get($post->fresh()->media, '0.meta.cover_offset_ms'))->toBe(1500)
+ ->and($post->fresh()->media[0]['id'])->toBe('video-1');
+ $page->assertNoJavaScriptErrors();
+})->with([
+ 'mastodon' => [ContentType::MastodonPost],
+ 'bluesky' => [ContentType::BlueskyPost],
+ 'threads' => [ContentType::ThreadsPost],
+ 'discord' => [ContentType::DiscordMessage],
+]);
+
function pickMediaEditorCoverImage(mixed $page): void
{
$png = base64_encode((string) file_get_contents(base_path('tests/fixtures/crop-quadrants.png')));
diff --git a/tests/Feature/Api/InlineMediaShapeTest.php b/tests/Feature/Api/InlineMediaShapeTest.php
index 2d14ae69c..ffcd55768 100644
--- a/tests/Feature/Api/InlineMediaShapeTest.php
+++ b/tests/Feature/Api/InlineMediaShapeTest.php
@@ -380,7 +380,7 @@ test('a failing item deletes the urls the request already downloaded', function
->and(Post::query()->count())->toBe(0);
});
-test('the alt shorthand is kept for images and ignored for other types', function () {
+test('the alt shorthand is kept for images and videos', function () {
$video = Media::factory()->video()->temporaryUpload($this->workspace)->stored()->create();
Storage::put($video->path, 'bytes');
$image = inlineMediaUpload($this);
@@ -394,7 +394,20 @@ test('the alt shorthand is kept for images and ignored for other types', functio
$media = Post::query()->sole()->media;
expect(data_get($media, '0.meta.alt_text'))->toBe('A photo')
- ->and(data_get($media, '1.meta'))->not->toHaveKey('alt_text');
+ ->and(data_get($media, '1.meta.alt_text'))->toBe('A clip');
+});
+
+test('the alt shorthand is ignored for a PDF', function () {
+ $document = Media::factory()->document()->temporaryUpload($this->workspace)->stored()->create();
+ Storage::put($document->path, 'bytes');
+
+ $this->withHeaders($this->headers)->postJson(route('api.posts.batch.store'), [
+ 'status' => 'draft',
+ 'media' => [['upload_token' => $document->upload_token, 'alt' => 'A deck']],
+ 'destinations' => [inlineMediaDestinations($this)[0]],
+ ]);
+
+ expect(data_get(Post::query()->sole()->media, '0.meta'))->not->toHaveKey('alt_text');
});
test('an upload from a role that cannot create posts is forbidden before the file is checked', function () {
diff --git a/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php b/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php
index 9fe9c80b1..7b3537704 100644
--- a/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php
+++ b/tests/Feature/Mcp/AttachMediaFromUploadToolTest.php
@@ -55,7 +55,7 @@ test('attaches an uploaded Media with alt text stored in meta', function () {
expect(data_get($this->post->fresh()->media, '0.meta.alt_text'))->toBe('A scenic mountain view');
});
-test('does not store alt text on a non-image upload', function () {
+test('stores alt text on a video upload', function () {
$video = Media::factory()->stored()->video()->create([
'mediable_type' => (new Workspace)->getMorphClass(),
'mediable_id' => $this->workspace->id,
@@ -67,13 +67,13 @@ test('does not store alt text on a non-image upload', function () {
->tool(AttachMediaFromUploadTool::class, [
'post_id' => $this->post->id,
'upload_token' => $video->upload_token,
- 'alt' => 'alt is meaningless for a video',
+ 'alt' => 'a cyclist crossing a bridge',
]);
$response->assertOk();
expect(data_get($this->post->fresh()->media, '0.type'))->toBe('video')
- ->and(data_get($this->post->fresh()->media, '0.meta.alt_text'))->toBeNull();
+ ->and(data_get($this->post->fresh()->media, '0.meta.alt_text'))->toBe('a cyclist crossing a bridge');
});
test('rejects alt text over the max length', function () {
diff --git a/tests/Feature/Mcp/PlatformToolTest.php b/tests/Feature/Mcp/PlatformToolTest.php
index 3ea885e43..550b7b922 100644
--- a/tests/Feature/Mcp/PlatformToolTest.php
+++ b/tests/Feature/Mcp/PlatformToolTest.php
@@ -64,6 +64,7 @@ test('list content types returns all platforms with constraints', function () {
'image_max_width',
'image_max_height',
'supports_alt_text',
+ 'supports_video_alt_text',
'supports_user_tags',
'supports_video_cover',
'supports_custom_video_cover',
diff --git a/tests/Feature/Services/Social/BlueskyPublisherTest.php b/tests/Feature/Services/Social/BlueskyPublisherTest.php
index 6e878156a..e22870ab7 100644
--- a/tests/Feature/Services/Social/BlueskyPublisherTest.php
+++ b/tests/Feature/Services/Social/BlueskyPublisherTest.php
@@ -720,7 +720,7 @@ test('bluesky publisher never publishes a partial image set', function (string $
/**
* Attach a single video to the post under test (mp4 by default).
*/
-function attachBlueskyVideo(Post $post, string $mimeType = 'video/mp4'): void
+function attachBlueskyVideo(Post $post, string $mimeType = 'video/mp4', array $meta = []): void
{
$post->update([
'media' => [[
@@ -729,6 +729,7 @@ function attachBlueskyVideo(Post $post, string $mimeType = 'video/mp4'): void
'url' => 'https://example.com/media/2026-01/test-video.mp4',
'mime_type' => $mimeType,
'original_filename' => 'test.mp4',
+ 'meta' => $meta,
]],
]);
}
@@ -787,6 +788,24 @@ function fakeBlueskyVideoPipeline(string $jobState = 'JOB_STATE_COMPLETED', bool
});
}
+test('bluesky publisher sends the video alt text, capped to the network limit, in the embed', function () {
+ $longAlt = str_repeat('a', 2100);
+ attachBlueskyVideo($this->post, meta: ['alt_text' => $longAlt]);
+
+ fakeBlueskyVideoPipeline();
+
+ $this->publisher->publish($this->post);
+
+ Http::assertSent(function ($request) {
+ if (! str_contains($request->url(), 'createRecord')) {
+ return false;
+ }
+
+ return data_get($request->data(), 'record.embed.$type') === 'app.bsky.embed.video'
+ && data_get($request->data(), 'record.embed.alt') === str_repeat('a', Platform::Bluesky->altTextMaxLength());
+ });
+});
+
test('bluesky publisher uploads a video and embeds it', function () {
attachBlueskyVideo($this->post);
@@ -803,7 +822,8 @@ test('bluesky publisher uploads a video and embeds it', function () {
return $embed
&& $embed['$type'] === 'app.bsky.embed.video'
- && data_get($embed, 'video.ref.$link') === 'bafvideo123';
+ && data_get($embed, 'video.ref.$link') === 'bafvideo123'
+ && ! array_key_exists('alt', $embed);
});
// The video goes to the video service, never to the PDS uploadBlob endpoint.
diff --git a/tests/Feature/Services/Social/DiscordPublisherTest.php b/tests/Feature/Services/Social/DiscordPublisherTest.php
index 0b5b81c01..6c0cb7aa7 100644
--- a/tests/Feature/Services/Social/DiscordPublisherTest.php
+++ b/tests/Feature/Services/Social/DiscordPublisherTest.php
@@ -238,7 +238,7 @@ test('omits the attachment description when the image has no alt text', function
});
});
-test('does not set a description on a non-image attachment even if it carries alt text', function () {
+test('sets the attachment description from a video alt text', function () {
$this->post->update([
'media' => [[
'id' => 'm1',
@@ -246,7 +246,7 @@ test('does not set a description on a non-image attachment even if it carries al
'url' => 'https://example.com/media/2026-01/clip.mp4',
'mime_type' => 'video/mp4',
'original_filename' => 'clip.mp4',
- 'meta' => ['alt_text' => 'alt text must not be sent for a video'],
+ 'meta' => ['alt_text' => 'a cyclist crossing a bridge'],
]],
]);
@@ -267,7 +267,7 @@ test('does not set a description on a non-image attachment even if it carries al
$payloadPart = collect($request->data())->firstWhere('name', 'payload_json');
$payload = json_decode(data_get($payloadPart, 'contents'), true);
- return ! array_key_exists('description', data_get($payload, 'attachments.0'));
+ return data_get($payload, 'attachments.0.description') === 'a cyclist crossing a bridge';
});
});
diff --git a/tests/Feature/Services/Social/FacebookPublisherTest.php b/tests/Feature/Services/Social/FacebookPublisherTest.php
index 6d9d0bef9..d26d723ad 100644
--- a/tests/Feature/Services/Social/FacebookPublisherTest.php
+++ b/tests/Feature/Services/Social/FacebookPublisherTest.php
@@ -364,6 +364,22 @@ test('facebook publisher can publish reel', function () {
&& $request['description'] === 'Check out this Facebook post!');
});
+test('facebook publisher sends no alt text with a video or a reel, which take none', function (ContentType $contentType, string $edge) {
+ $this->post->update(['content_type' => $contentType]);
+ $this->post->update(['media' => [[...facebookVideoMedia()[0], 'meta' => ['alt_text' => 'a cyclist crossing a bridge']]]]);
+
+ Http::fake(facebookVideoUploadFakes($edge));
+
+ $this->publisher->publish($this->post);
+
+ Http::assertSent(fn ($request) => str_contains($request->url(), "/page_123/{$edge}"));
+ Http::assertNotSent(fn ($request) => array_key_exists('alt_text_custom', $request->data())
+ || array_key_exists('alt_text', $request->data()));
+})->with([
+ 'video' => [ContentType::FacebookPost, 'videos'],
+ 'reel' => [ContentType::FacebookReel, 'video_reels'],
+]);
+
test('facebook publisher can publish video story', function () {
$this->post->update(['content_type' => ContentType::FacebookStory]);
$this->post->update(['media' => facebookVideoMedia()]);
diff --git a/tests/Feature/Services/Social/InstagramPublisherTest.php b/tests/Feature/Services/Social/InstagramPublisherTest.php
index bd42214d2..386f7d338 100644
--- a/tests/Feature/Services/Social/InstagramPublisherTest.php
+++ b/tests/Feature/Services/Social/InstagramPublisherTest.php
@@ -142,6 +142,31 @@ test('instagram publisher can publish reel', function () {
});
});
+test('instagram publisher sends no alt text on a reel, which takes none', function () {
+ $this->post->update(['content_type' => ContentType::InstagramReel]);
+ $this->post->update(['media' => [[
+ 'id' => 'test-media-video',
+ 'path' => 'media/2026-01/test-video.mp4',
+ 'url' => 'https://example.com/media/2026-01/test-video.mp4',
+ 'mime_type' => 'video/mp4',
+ 'original_filename' => 'test.mp4',
+ 'meta' => ['alt_text' => 'a cyclist crossing a bridge'],
+ ]]]);
+
+ Http::fake([
+ 'https://graph.instagram.com/v25.0/ig_123456789/media' => Http::response(['id' => 'container-123'], 200),
+ 'https://graph.instagram.com/v25.0/container-123*' => Http::response(['status_code' => 'FINISHED'], 200),
+ 'https://graph.instagram.com/v25.0/ig_123456789/media_publish' => Http::response(['id' => 'reel-123456789'], 200),
+ 'https://graph.instagram.com/v25.0/reel-123456789*' => Http::response(['permalink' => 'https://www.instagram.com/reel/ABC123/'], 200),
+ ]);
+
+ $this->publisher->publish($this->post);
+
+ Http::assertSent(fn ($request) => str_ends_with($request->url(), '/ig_123456789/media')
+ && data_get($request->data(), 'media_type') === 'REELS'
+ && ! array_key_exists('alt_text', $request->data()));
+});
+
test('instagram publisher fits an image story to 9:16 and posts the hosted copy', function () {
Storage::fake();
$this->post->update(['content_type' => ContentType::InstagramStory]);
diff --git a/tests/Feature/Services/Social/MastodonPublisherTest.php b/tests/Feature/Services/Social/MastodonPublisherTest.php
index bcee94f9c..807f89b11 100644
--- a/tests/Feature/Services/Social/MastodonPublisherTest.php
+++ b/tests/Feature/Services/Social/MastodonPublisherTest.php
@@ -267,7 +267,7 @@ test('mastodon publisher sends no description part when image has no alt text',
@unlink($optimizedFile);
});
-test('mastodon publisher does not send a description for a non-image even if it carries alt text', function () {
+test('mastodon publisher sends the alt text of a video as its media description', function () {
$this->post->update([
'media' => [
[
@@ -276,7 +276,7 @@ test('mastodon publisher does not send a description for a non-image even if it
'url' => 'https://example.com/media/2026-01/clip.mp4',
'mime_type' => 'video/mp4',
'original_filename' => 'clip.mp4',
- 'meta' => ['alt_text' => 'alt must not be sent for a video'],
+ 'meta' => ['alt_text' => 'a cyclist crossing a bridge'],
],
],
]);
@@ -309,7 +309,7 @@ test('mastodon publisher does not send a description for a non-image even if it
return false;
}
- return collect($request->data())->firstWhere('name', 'description') === null;
+ return data_get(collect($request->data())->firstWhere('name', 'description'), 'contents') === 'a cyclist crossing a bridge';
});
});
diff --git a/tests/Feature/Services/Social/ThreadsPublisherTest.php b/tests/Feature/Services/Social/ThreadsPublisherTest.php
index 2a283d847..60548af8e 100644
--- a/tests/Feature/Services/Social/ThreadsPublisherTest.php
+++ b/tests/Feature/Services/Social/ThreadsPublisherTest.php
@@ -815,7 +815,7 @@ test('threads publisher omits alt_text from single image container when no alt t
});
});
-test('threads publisher sends alt text on image carousel children but never on video children', function () {
+test('threads publisher sends alt text on image and video carousel children', function () {
$imageAlt = str_repeat('x', 1500);
$this->post->update([
@@ -834,7 +834,7 @@ test('threads publisher sends alt text on image carousel children but never on v
'url' => 'https://example.com/media/2026-01/test-video.mp4',
'mime_type' => 'video/mp4',
'original_filename' => 'test.mp4',
- 'meta' => ['alt_text' => 'video alt text must never be sent'],
+ 'meta' => ['alt_text' => 'a cyclist crossing a bridge'],
],
],
]);
@@ -871,7 +871,47 @@ test('threads publisher sends alt text on image carousel children but never on v
return str_ends_with($request->url(), '/123456789/threads')
&& data_get($data, 'video_url') !== null
- && ! array_key_exists('alt_text', $data);
+ && data_get($data, 'alt_text') === 'a cyclist crossing a bridge';
+ });
+});
+
+test('threads publisher sends alt text on a single video container', function () {
+ $this->post->update([
+ 'media' => [
+ [
+ 'id' => 'test-media-video',
+ 'path' => 'media/2026-01/test-video.mp4',
+ 'url' => 'https://example.com/media/2026-01/test-video.mp4',
+ 'mime_type' => 'video/mp4',
+ 'original_filename' => 'test.mp4',
+ 'meta' => ['alt_text' => 'a cyclist crossing a bridge'],
+ ],
+ ],
+ ]);
+
+ Http::fake([
+ 'https://graph.threads.net/v1.0/123456789/threads' => Http::response([
+ 'id' => 'container-123',
+ ], 200),
+ 'https://graph.threads.net/v1.0/container-123*' => Http::response([
+ 'status' => 'FINISHED',
+ ], 200),
+ 'https://graph.threads.net/v1.0/123456789/threads_publish' => Http::response([
+ 'id' => 'post-video-alt-123',
+ ], 200),
+ 'https://graph.threads.net/v1.0/post-video-alt-123*' => Http::response([
+ 'permalink' => 'https://www.threads.net/@testuser/post/VIDEOALT123',
+ ], 200),
+ ]);
+
+ $this->publisher->publish($this->post);
+
+ Http::assertSent(function ($request) {
+ $data = $request->data();
+
+ return str_ends_with($request->url(), '/123456789/threads')
+ && data_get($data, 'media_type') === 'VIDEO'
+ && data_get($data, 'alt_text') === 'a cyclist crossing a bridge';
});
});
diff --git a/tests/Unit/Enums/ContentTypeTest.php b/tests/Unit/Enums/ContentTypeTest.php
index 79d558a3d..b3d5bd5ce 100644
--- a/tests/Unit/Enums/ContentTypeTest.php
+++ b/tests/Unit/Enums/ContentTypeTest.php
@@ -550,7 +550,7 @@ test('an instagram account connected through facebook gets the same post types a
test('a type without images lists no alt text and a type without video accepts no mov', function (ContentType $type) {
if (! $type->supportsImage()) {
- expect($type->supportsAltText())->toBeFalse();
+ expect($type->supportsImageAltText())->toBeFalse();
}
if (! $type->supportsVideo()) {
@@ -559,6 +559,14 @@ test('a type without images lists no alt text and a type without video accepts n
expect($type->toListingArray())->toMatchArray([
'accepts_mov' => $type->acceptsMov(),
- 'supports_alt_text' => $type->supportsAltText(),
+ 'supports_alt_text' => $type->supportsImageAltText(),
+ 'supports_video_alt_text' => $type->supportsVideoAltText(),
]);
})->with(ContentType::cases());
+
+test('only bluesky, mastodon, threads and discord take alt text on a video', function (ContentType $type) {
+ $expected = in_array($type, [ContentType::BlueskyPost, ContentType::MastodonPost, ContentType::ThreadsPost, ContentType::DiscordMessage], true);
+
+ expect($type->supportsVideoAltText())->toBe($expected)
+ ->and($type->mediaRules()['supports_video_alt_text'])->toBe($expected);
+})->with(ContentType::cases());
diff --git a/tests/Unit/Enums/MediaEditorPresetsParityTest.php b/tests/Unit/Enums/MediaEditorPresetsParityTest.php
index b0c1cead8..2f53f36d7 100644
--- a/tests/Unit/Enums/MediaEditorPresetsParityTest.php
+++ b/tests/Unit/Enums/MediaEditorPresetsParityTest.php
@@ -95,3 +95,12 @@ test('the no-channel presets sit inside every content type bounds or are filtere
->toBe(['freeform', 'original', ...$inside], $type->value);
}
});
+
+test('the typescript media editor offers alt text on a video exactly where the backend takes it', function () {
+ $output = runMediaEditorPresetsHarness();
+
+ foreach (ContentType::cases() as $type) {
+ expect(in_array('alt', data_get($output, "videoTabs.{$type->value}"), true))
+ ->toBe($type->supportsVideoAltText(), $type->value);
+ }
+});
diff --git a/tests/Unit/Enums/PlatformTest.php b/tests/Unit/Enums/PlatformTest.php
index 223e21eed..e132aec84 100644
--- a/tests/Unit/Enums/PlatformTest.php
+++ b/tests/Unit/Enums/PlatformTest.php
@@ -379,7 +379,7 @@ test('google business has correct label and color', function () {
test('google business has correct media rules', function () {
expect(Platform::GoogleBusiness->allowedMediaTypes())->toBe([MediaType::Image]);
expect(Platform::GoogleBusiness->maxImages())->toBe(1);
- expect(Platform::GoogleBusiness->supportsAltText())->toBeFalse();
+ expect(Platform::GoogleBusiness->supportsImageAltText())->toBeFalse();
expect(Platform::GoogleBusiness->maxContentLength())->toBe(1500);
});
diff --git a/tests/Unit/PlatformAltTextTest.php b/tests/Unit/PlatformAltTextTest.php
index 82dffa963..03b70d95a 100644
--- a/tests/Unit/PlatformAltTextTest.php
+++ b/tests/Unit/PlatformAltTextTest.php
@@ -24,11 +24,11 @@ test('altTextMaxLength is null for platforms without alt-text support', function
->and(Platform::YouTube->altTextMaxLength())->toBeNull();
});
-test('supportsAltText mirrors altTextMaxLength', function () {
- expect(Platform::Bluesky->supportsAltText())->toBeTrue()
- ->and(Platform::LinkedInPage->supportsAltText())->toBeTrue()
- ->and(Platform::InstagramFacebook->supportsAltText())->toBeTrue()
- ->and(Platform::TikTok->supportsAltText())->toBeFalse();
+test('supportsImageAltText mirrors altTextMaxLength', function () {
+ expect(Platform::Bluesky->supportsImageAltText())->toBeTrue()
+ ->and(Platform::LinkedInPage->supportsImageAltText())->toBeTrue()
+ ->and(Platform::InstagramFacebook->supportsImageAltText())->toBeTrue()
+ ->and(Platform::TikTok->supportsImageAltText())->toBeFalse();
});
test('altTextMaxLength is defined for every platform so a new case cannot slip through', function () {
@@ -38,3 +38,13 @@ test('altTextMaxLength is defined for every platform so a new case cannot slip t
expect($max === null || (is_int($max) && $max > 0))->toBeTrue();
}
});
+
+test('only bluesky, mastodon, threads and discord take alt text on a video, each also taking it on an image', function (Platform $platform) {
+ $expected = in_array($platform, [Platform::Bluesky, Platform::Mastodon, Platform::Threads, Platform::Discord], true);
+
+ expect($platform->supportsVideoAltText())->toBe($expected);
+
+ if ($expected) {
+ expect($platform->supportsImageAltText())->toBeTrue();
+ }
+})->with(Platform::cases());
diff --git a/tests/fixtures/media-editor-harness.ts b/tests/fixtures/media-editor-harness.ts
index b44a82a88..0f68c5249 100644
--- a/tests/fixtures/media-editor-harness.ts
+++ b/tests/fixtures/media-editor-harness.ts
@@ -21,7 +21,7 @@ registerHooks({
: nextResolve(specifier, context),
});
-const { cropPresetsFor, presetValuesFor } = await import(
+const { cropPresetsFor, editorTabsFor, presetValuesFor } = await import(
pathToFileURL(path.join(path.resolve(resourcesDir), 'lib/mediaEditor.ts')).href
);
const { toMediaRules } = await import(
@@ -46,6 +46,12 @@ const results = Object.fromEntries(
Object.entries(rules).map(([contentType, rule]) => [contentType, valuesFor(toMediaRules(rule))]),
);
+const video = { id: 'video', type: 'video', url: 'https://example.com/clip.mp4', mime_type: 'video/mp4' };
+
+const videoTabs = Object.fromEntries(
+ Object.entries(rules).map(([contentType, rule]) => [contentType, editorTabsFor(video, [toMediaRules(rule)])]),
+);
+
const noChannelResults = Object.fromEntries(
Object.entries(rules).map(([contentType, rule]) => [contentType, noChannelValuesFor(toMediaRules(rule))]),
);
@@ -54,6 +60,7 @@ console.log(
JSON.stringify({
contentTypes: results,
noChannelWithinBounds: noChannelResults,
+ videoTabs,
noChannel: cropPresetsFor(presetValuesFor([], defaults)).map((preset: Preset) => preset.value),
}),
);