From f3804ee7ddcaf1d6edee2b1fcc235f024aacee0b Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 6 Aug 2019 22:08:21 +0000 Subject: [PATCH] Array instead of a string --- twitter/twitter.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index 79f37e1f..ac23b84d 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -639,10 +639,9 @@ function twitter_post_hook(App $a, array &$b) if (!empty($msgarr['images'])) { try { - $post['media_ids'] = ''; - $counter = 0; + $media_ids = []; foreach ($msgarr['images'] as $image) { - if (++$counter > 4) { + if (count($media_ids) == 4) { continue; } @@ -656,7 +655,7 @@ function twitter_post_hook(App $a, array &$b) unlink($tempfile); if (isset($media->media_id_string)) { - $post['media_ids'] .= $media->media_id_string . ','; + $media_ids[] = $media->media_id_string; if (!empty($image['description'])) { $data = ['media_id' => $media->media_id_string, @@ -668,7 +667,7 @@ function twitter_post_hook(App $a, array &$b) throw new Exception('Failed upload of ' . $image['url']); } } - $post['media_ids'] = rtrim($post['media_ids'], ','); + $post['media_ids'] = implode(',', $media_ids); if (empty($post['media_ids'])) { unset($post['media_ids']); } -- 2.39.5