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.

Normalize alt-text null checks across publishers

Paulo Castellano0e93d7e5e3d8
diff --git a/app/Enums/SocialAccount/Platform.php b/app/Enums/SocialAccount/Platform.php
index 25f2b743c..73629c8fc 100644
--- a/app/Enums/SocialAccount/Platform.php
+++ b/app/Enums/SocialAccount/Platform.php
@@ -149,6 +149,10 @@ enum Platform: string
};
}
+ /**
+ * Whether the platform's API accepts image alt text (accessibility
+ * description) on published media.
+ */
public function supportsAltText(): bool
{
return $this->altTextMaxLength() !== null;
diff --git a/app/Services/Social/Discord/DiscordPublisher.php b/app/Services/Social/Discord/DiscordPublisher.php
index d741d01f1..f4d88a602 100644
--- a/app/Services/Social/Discord/DiscordPublisher.php
+++ b/app/Services/Social/Discord/DiscordPublisher.php
@@ -129,7 +129,9 @@ class DiscordPublisher
$attachment = ['id' => $index, 'filename' => $filename];
- if ($alt = $item->altText()) {
+ $alt = $item->altText();
+
+ if ($alt !== null) {
$attachment['description'] = mb_substr($alt, 0, Platform::Discord->altTextMaxLength());
}
diff --git a/app/Services/Social/FacebookPublisher.php b/app/Services/Social/FacebookPublisher.php
index 6f351b9f0..6386bb1bd 100644
--- a/app/Services/Social/FacebookPublisher.php
+++ b/app/Services/Social/FacebookPublisher.php
@@ -136,7 +136,9 @@ class FacebookPublisher
$payload['message'] = $content;
}
- if ($alt = $this->altFor($media)) {
+ $alt = $this->altFor($media);
+
+ if ($alt !== null) {
$payload['alt_text_custom'] = $alt;
}
@@ -175,7 +177,9 @@ class FacebookPublisher
'access_token' => $accessToken,
];
- if ($alt = $this->altFor($media)) {
+ $alt = $this->altFor($media);
+
+ if ($alt !== null) {
$uploadPayload['alt_text_custom'] = $alt;
}
diff --git a/app/Services/Social/InstagramPublisher.php b/app/Services/Social/InstagramPublisher.php
index bd751bdd1..2fe669f65 100644
--- a/app/Services/Social/InstagramPublisher.php
+++ b/app/Services/Social/InstagramPublisher.php
@@ -89,7 +89,9 @@ class InstagramPublisher
'access_token' => $accessToken,
];
- if ($alt = $this->altFor($media)) {
+ $alt = $this->altFor($media);
+
+ if ($alt !== null) {
$params['alt_text'] = $alt;
}
@@ -215,7 +217,9 @@ class InstagramPublisher
} else {
$params['image_url'] = $this->cropImageForAspectRatio($media->url, $aspectRatio);
- if ($alt = $this->altFor($media)) {
+ $alt = $this->altFor($media);
+
+ if ($alt !== null) {
$params['alt_text'] = $alt;
}
}
diff --git a/app/Services/Social/ThreadsPublisher.php b/app/Services/Social/ThreadsPublisher.php
index e5bf968ba..89f87cfc9 100644
--- a/app/Services/Social/ThreadsPublisher.php
+++ b/app/Services/Social/ThreadsPublisher.php
@@ -109,7 +109,9 @@ class ThreadsPublisher
'access_token' => $accessToken,
];
- if ($alt = $this->altFor($media)) {
+ $alt = $this->altFor($media);
+
+ if ($alt !== null) {
$params['alt_text'] = $alt;
}
@@ -193,7 +195,9 @@ class ThreadsPublisher
$params['media_type'] = 'IMAGE';
$params['image_url'] = $media->url;
- if ($alt = $this->altFor($media)) {
+ $alt = $this->altFor($media);
+
+ if ($alt !== null) {
$params['alt_text'] = $alt;
}
}