Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/social-web/style-feed-stage-rtl.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/social-web/style-feed-stage.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions includes/class-attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ private static function import_files_for_object( $attachments, $object_id, $obje
self::append_files_to_content( $object_id, $files, $object_type );
}

// Add inline mappings to the returned files.
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- We only need the new URL, not the old one.
foreach ( $inline_mappings as $old_url => $new_url ) {
$files[] = array(
'url' => $new_url,
'mime_type' => 'image/*',
);
}

return $files;
}

Expand Down
32 changes: 32 additions & 0 deletions includes/class-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,17 @@ public static function register_post_post_type() {
'sanitize_callback' => 'absint',
)
);

\register_post_meta(
Posts::POST_TYPE,
'_activitypub_featured_image_url',
array(
'type' => 'string',
'single' => true,
'description' => 'URL of the featured image from ActivityPub attachments.',
'sanitize_callback' => 'sanitize_url',
)
);
}

/**
Expand Down Expand Up @@ -691,6 +702,27 @@ public static function register_ap_post_actor_rest_field() {
),
)
);

\register_rest_field(
Posts::POST_TYPE,
'featured_image',
array(
/**
* Get the featured image for an ap_post.
*
* @param array $response Prepared response array.
* @return string|null The image URL or null if not found.
*/
'get_callback' => function ( $response ) {
return \get_post_meta( $response['id'], '_activitypub_featured_image_url', true ) ?: null;
},
'schema' => array(
'description' => 'Featured image URL from ActivityPub attachments',
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
)
);
}

/**
Expand Down
Loading