[Mod] Rich Link Previews

Started by Deaks, Nov 20, 2026, 09:00 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Deaks

Rich Link Previews v1.0.3
Automatic preview cards for links shared in SMF 2.1.x posts
By BoredSkull · ISC Licence

Rich Link Previews gives readers a glimpse of a shared page before they open it. When a member posts or edits a message, supported links can display a card beneath the post with the page title, description and thumbnail. Members can paste a URL or use SMF's existing link buttons.

SMF Customisation Site — Rich Link Previews (awaiting approval)



Which Links Get a Preview?

  • External pages — The mod recognises plain URLs and links added using SMF's [tt]url[/tt] and [tt]iurl[/tt] BBCode tags. It reads Open Graph, Twitter Card and standard HTML metadata. If a site blocks the request or provides no usable metadata, a basic card can still show its domain and link.
  • Forum topics and boards — Optional internal previews use information from your forum database. Board permissions determine what each reader can see, including when someone shares a link to a private board in a public topic.
  • Quoted and embedded content — Links inside quotes, code blocks, image tags and spoilers are skipped, as are direct links to images and downloadable files. YouTube links are left to SMF's video embedding or the YouTube Video Card mod, avoiding duplicate previews.

Cards adapt to light and dark themes. On smaller screens, the thumbnail moves above the text to keep the title and description readable.

Installation and Settings

Rich Link Previews requires SMF 2.1.x and PHP 7.0 or newer. External website previews require the PHP cURL extension. The DOM and intl extensions are optional but recommended.

Upload the package through Admin → Packages → Download Packages → Upload Package and select Install Now. Then open Admin → Configuration → Modifications → Rich Link Previews.

  • Display — Enable or disable previews, choose whether to include internal forum links and thumbnails, and set a limit of 1 to 20 cards per post.
  • Domain exclusions — Exclude a website and its subdomains from preview generation.
  • Fetching and refresh — Set request timeouts, maximum download size and how often stored metadata is refreshed. Enable background fetching so posts can save while SMF retrieves the previews. Stored metadata is reused when readers open the topic.
  • Existing posts — Use the maintenance tool to queue previews for older posts in batches of 100, without asking members to edit them.

How External Requests Are Handled

The fetcher accepts HTTP and HTTPS on standard ports and checks redirect destinations before connecting. It blocks private, loopback, link-local, carrier-grade NAT and reserved address ranges, and checks both IPv4 and IPv6 addresses. Connections use the validated IP address to guard against DNS rebinding.

Only HTML responses are used for metadata. Downloads are size-limited and can stop once the page's head section has been retrieved. Titles and descriptions are stored as plain text and escaped when displayed.



Release History · v1.0.2

  • Improved PHP compatibility on servers without the optional mbstring extension.
  • Improved text escaping for internal topic and board previews.
  • Fixed overlapping post edits so an older fetch cannot overwrite the preview for a newer edit.
  • Updated uninstallation to remove pending background fetch jobs while retaining stored preview metadata.
  • Preserved existing settings and previously generated previews during upgrades.

Support and Suggestions

For help or bug reports, please use the Support board. Include your SMF and Rich Link Previews versions, whether the link points to your forum or an external site, and what appeared beneath the post. If the issue affects a public page, an example link will help us check it. Feature suggestions are welcome on the Requests board.
  • 0 reactions

    Members who reacted


Deaks

Fixed in 1.0.3:

  • Links were wrongly saved as failed. When a post's time limit ran out, every remaining link was recorded as failed without being tried. In my test, a working page got no preview. Worse, that failure is shared across posts, so for 24 hours no post could preview that site, and the original post kept a basic card permanently. Now untried links are left alone and looked up again in the background, and a test retry gave the working page its proper preview. A chain of slow redirects counts as tried, so it can't be retried forever.
  • The weekly clean-up never ran with "Fetch previews in the background" off. Data for deleted posts piled up. It's now queued on its own, and a test run removed the leftover data.
  • 0 reactions

    Members who reacted