Skip to content

Attach link previews on LinkedIn and Facebook text posts - #367

Open
paulocastellano wants to merge 15 commits into
mainfrom
fix/social-link-previews
Open

paulocastellano wants to merge 15 commits into
mainfrom
fix/social-link-previews

Conversation

@paulocastellano

Copy link
Copy Markdown
Contributor

Summary

  • LinkedIn text posts that contain a URL are published as an article (content.article) with the Open Graph title, description, and thumbnail. The Posts API does not scrape URLs on its own.
  • Facebook text posts send the first URL as the Page feed link parameter, which is what makes Facebook render the preview. If the scrape fails (1609005), the post is published again without the card.
  • Attached media still wins on both networks. Mastodon is unchanged (the instance unfurls the link). The editor preview now shows the card on LinkedIn, Facebook, and Mastodon.

Test plan

  • Publish a text-only post with a public URL to LinkedIn (profile and Page) and confirm the article card appears.
  • Publish the same post to a Facebook Page and confirm the link preview appears.
  • Publish a post that also has an image and confirm the image is shown instead of the link card.
  • Confirm a Mastodon post with a URL still unfurls on the instance.
  • In the composer, check that LinkedIn, Facebook, and Mastodon previews show the card while typing a URL with no media attached.

Paulo Castellano added 15 commits September 21, 2026 16:56
Neither API unfurls a URL left in the caption: LinkedIn needs an article payload, and Facebook only scrapes when the Page feed post sets link. A text-only post now sends that card from the first URL, and the editor preview shows it.
facebook.com, fb.com and fb.me are no longer sent as the Page feed link, and a scrape or invalid-URL error retries once without the card. LinkedIn still publishes the text if the preview lookup fails, and the thumbnail download stays off private hosts.
The editor now skips facebook.com, fb.com and fb.me the same way the publisher does, and a link rejection that is retried as plain text is no longer logged as a failed post.
…h each.

The LinkedIn article thumbnail shares the optimize-and-upload step with
regular image posts instead of carrying its own copy, and each method removes
only the temp file it created. The Facebook text post with a link lives in
its own method, so the retry without the link reads top to bottom.
The publisher asks rejectsLink() instead of comparing Graph codes inline; the
codes live next to the rest of the Facebook error table.
Title and description trimming, a non-image og:image, a dead token during the
thumbnail upload, the article under a company page, a retry that fails too,
and a dead token on the first Facebook attempt.
A slow preview used to revive a card the user had already removed, or
overwrite the card of the link they typed next. The response now only lands
when the URL it was fetched for is still the one in the caption.
Changing the caption URL now clears the old card immediately and bumps a
request id so an in-flight response cannot land on the wrong caption. The
LinkedIn image/thumbnail path also refuses a failed tempnam or fopen instead
of feeding false into unlink.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant