Download the PHP package ekumanov/flarum-ext-discussion-og-meta without Composer

On this page you can find all versions of the php package ekumanov/flarum-ext-discussion-og-meta. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package flarum-ext-discussion-og-meta

Discussion OpenGraph Meta for Flarum 2.0

Latest Stable Version Total Downloads Backend

Emits per-discussion OpenGraph and Twitter Card meta tags in the <head> of Flarum 2.0 discussion pages, so when someone pastes a discussion URL into Slack, Discord, Facebook, X, iMessage, Telegram, or any other unfurler, the preview shows the actual discussion title and first-post excerpt — not the same generic forum description every time.

Built with Claude Code.

Why this exists

Out of the box, every page on a Flarum forum carries the same single forum-level <meta name="description">. So a link to https://example.com/d/2449-pianos-and-design previews everywhere as the forum's generic description ("Piano forum for piano, keyboard, synth, players and music enthusiasts..."), regardless of what the thread is actually about. That makes shared links look interchangeable and kills click-through.

This extension fixes that by reading the discussion + first-post data that Flarum's discussion route handler already loads, and turning it into a small block of per-page OpenGraph + Twitter meta tags.

What it emits

On every public discussion page (/d/{id}-{slug}):

twitter:card switches to summary_large_image when the first post contains an image; otherwise it's plain summary. og:image and twitter:image are only emitted when an image is found.

What it does NOT do

What it skips

Defensively, the meta tags are not injected when the discussion is:

Flarum's API already 404s these for unauthenticated viewers (which is what link-unfurl bots are), so the meta tags would never reach a crawler anyway — but the explicit skip belt-and-braces the case where a privileged user copies a non-public discussion URL.

Install

That's it — no settings to configure.

Verify

After install, on any public discussion page:

You should see the og:* and twitter:* tags reflecting the discussion's actual title and first-post content.

How it works

The extension registers a single Extend\Frontend('forum')->content(AddOgMetaTags::class) callback. It runs after Flarum's built-in discussion route handler has populated $document->payload['apiDocument'] with the JSON:API document for the discussion (including the eager-loaded firstPost). So the callback adds no DB queries of its own — it just reads what core has already fetched and formats it into meta tags.

The description build pipeline:

  1. Read firstPost.attributes.contentHtml from the API document.
  2. Replace every HTML tag with a single space (so </p><p> doesn't concatenate text), then html_entity_decode, then collapse whitespace.
  3. Truncate at the last word boundary before 200 chars and append .

The image scan:

  1. Short-circuit if contentHtml doesn't contain <img.
  2. preg_match_all for <img> tags, skip ones whose class contains emoji or whose src is a data: URI or /emoji/ path.
  3. Use the first survivor as og:image.

Performance

Zero DB queries. The description regex scales linearly with first-post HTML size and runs in microseconds for typical posts. Measured against the pianoclack prod-mirror over 20 iterations per condition, the with-extension vs. without-extension delta sat well inside curl measurement noise (±70 ms stddev for a ~1 s debug-mode render).

No client-side JS, no CSS, no asset rebuild.

Compatibility

Plays nicely with fof/upload (image attachments become og:image), fof/byobu (private discussions are skipped), and flarum/approval (unapproved discussions are skipped).

License

MIT — see LICENSE.


All versions of flarum-ext-discussion-og-meta with dependencies

PHP Build Version
Package Version
Requires flarum/core Version ^2.0@beta
php Version ^8.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ekumanov/flarum-ext-discussion-og-meta contains the following files

Loading the files please wait ...