Skip to content

Commit 46a7358

Browse files
fix: include post link when sharing as image
1 parent 7aad2c4 commit 46a7358

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

includes/admin/helpers/class-rop-bluesky-api.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -312,33 +312,33 @@ public function create_post( $did, $post, $post_type, $hashtags, $access_token =
312312
'description' => isset( $post['content'] ) ? $post['content'] : '',
313313
),
314314
);
315-
316-
if (
317-
isset( $post['post_image'], $post['mimetype'] ) &&
318-
! empty( $post['post_image'] ) &&
319-
! empty( $post['mimetype'] )
320-
) {
321-
$image_blob = $this->upload_blob( $access_token, $post['post_image'], $post['mimetype']['type'] );
322-
323-
if ( false !== $image_blob ) {
324-
$record['embed']['external']['thumb'] = $image_blob;
325-
}
326-
}
327315
}
328316

329317
if ( $post_type === 'image' && isset( $post['post_image'], $post['mimetype'] ) && ! empty( $post['post_image'] ) && ! empty( $post['mimetype'] ) ) {
330318
$image_blob = $this->upload_blob( $access_token, $post['post_image'], $post['mimetype']['type'] );
331319

332320
if ( false !== $image_blob ) {
333-
$record['embed'] = array(
334-
'$type' => 'app.bsky.embed.images',
335-
'images' => array(
336-
array(
337-
'alt' => isset( $post['title'] ) ? $post['title'] : '',
338-
'image' => $image_blob,
321+
if ( isset( $post['post_url'] ) && ! empty( $post['post_url'] ) ) {
322+
$record['embed'] = array(
323+
'$type' => 'app.bsky.embed.external',
324+
'external' => array(
325+
'uri' => $post['post_url'],
326+
'title' => isset( $post['title'] ) ? $post['title'] : '',
327+
'description' => isset( $post['content'] ) ? $post['content'] : '',
328+
'thumb' => $image_blob,
339329
),
340-
),
341-
);
330+
);
331+
} else {
332+
$record['embed'] = array(
333+
'$type' => 'app.bsky.embed.images',
334+
'images' => array(
335+
array(
336+
'alt' => isset( $post['title'] ) ? $post['title'] : '',
337+
'image' => $image_blob,
338+
),
339+
),
340+
);
341+
}
342342
}
343343
}
344344

0 commit comments

Comments
 (0)