Skip to content

atmosphere_post_embed

github-actions[bot] edited this page May 20, 2026 · 14 revisions

Filters the embed attached to a Bluesky post record.

Fires for every composition strategy, including short-form (where the default is null — short-form posts ship without an embed unless something opts in). Consumers can:

  • Replace the default external link card with a richer embed type (app.bsky.embed.images, app.bsky.embed.video, app.bsky.embed.record).
  • Attach an embed to a short-form post that would otherwise ship plain.
  • Suppress the default embed by returning null.

Valid returns are null or an array with a non-empty string $type key. Non-array returns, empty arrays, and arrays without a non-empty string $type are rejected with _doing_it_wrong and the pre-filter value is restored — protects the applyWrites batch from a misbehaving listener and keeps every composition strategy treating half-formed returns the same way.

The filter is called after the default embed has been built, so listeners can read the default before deciding to replace it (e.g. a photo-projector that wants to fall back to the external card when the post has zero image attachments).

Not fired for redacted (password-protected) transforms — the record carries no text or tags in that branch and exposing the post object to embed filters would leak the protected payload.

(null for short-form, an app.bsky.embed.external card otherwise). 'link-card', or 'teaser-thread'.

Auto-generated Example

/**
 * Filters the embed attached to a Bluesky post record.
 * 
 * Fires for every composition strategy, including short-form
 * (where the default is `null` — short-form posts ship without
 * an embed unless something opts in). Consumers can:
 * 
 * - Replace the default external link card with a richer
 * embed type (`app.bsky.embed.images`, `app.bsky.embed.video`,
 * `app.bsky.embed.record`).
 * - Attach an embed to a short-form post that would otherwise
 * ship plain.
 * - Suppress the default embed by returning null.
 * 
 * Valid returns are `null` or an array with a non-empty string
 * `$type` key. Non-array returns, empty arrays, and arrays
 * without a non-empty string `$type` are rejected with
 * `_doing_it_wrong` and the pre-filter value is restored —
 * protects the applyWrites batch from a misbehaving listener
 * and keeps every composition strategy treating half-formed
 * returns the same way.
 * 
 * The filter is called *after* the default embed has been
 * built, so listeners can read the default before deciding to
 * replace it (e.g. a photo-projector that wants to fall back to
 * the external card when the post has zero image attachments).
 * 
 * Not fired for redacted (password-protected) transforms — the
 * record carries no text or tags in that branch and exposing the
 * post object to embed filters would leak the protected payload.
 * 
 * (null for short-form, an
 * `app.bsky.embed.external` card
 * otherwise).
 * 'link-card', or 'teaser-thread'.
 *
 * @param array   $embed 
 * @param WP_Post $post 
 * @param mixed $string 
 * @return array The filtered value.
 */
function my_atmosphere_post_embed_callback( array $embed = null, WP_Post $post, string ) {
    // Your code here.
    return null;
}
add_filter( 'atmosphere_post_embed', 'my_atmosphere_post_embed_callback', 10, 3 );

Parameters

  • array|null $embed Default embed for this strategy
  • WP_Post $post The post being transformed.
  • string $strategy Composition strategy: 'short-form', Other variable names: $strategy

Files

\apply_filters( 'atmosphere_post_embed', $embed, $this->object, $strategy )

← All Hooks

Clone this wiki locally