-
Notifications
You must be signed in to change notification settings - Fork 1
atmosphere_post_embed
Filters the embed attached to a Bluesky post record.
Fires for every composition strategy. The default for short-form
posts is an app.bsky.embed.images record when the post has
images (in-body core/image blocks, or the featured image as a
fallback), and null otherwise. 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 (e.g. an image-free aside).
- 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.
(an app.bsky.embed.images record
for short-form posts with images,
null for short-form posts without
images, an app.bsky.embed.external
card for the link-card and
teaser-thread strategies).
'link-card', or 'teaser-thread'.
/**
* Filters the embed attached to a Bluesky post record.
*
* Fires for every composition strategy. The default for short-form
* posts is an `app.bsky.embed.images` record when the post has
* images (in-body `core/image` blocks, or the featured image as a
* fallback), and `null` otherwise. 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 (e.g. an image-free aside).
* - 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.
*
* (an `app.bsky.embed.images` record
* for short-form posts with images,
* null for short-form posts without
* images, an `app.bsky.embed.external`
* card for the link-card and
* teaser-thread strategies).
* '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 );-
array|null$embedDefault embed for this strategy -
WP_Post$postThe post being transformed. -
string$strategy Composition strategy: 'short-form', Other variable names:$strategy
\apply_filters( 'atmosphere_post_embed', $embed, $this->object, $strategy )