mirror of
https://github.com/friendica/friendica
synced 2025-04-26 22:30:18 +00:00
Avoid adding the same attachments in shared posts
This commit is contained in:
parent
8541e248bb
commit
94e36f7970
2 changed files with 28 additions and 18 deletions
|
@ -447,11 +447,12 @@ class Media
|
|||
/**
|
||||
* Split the attachment media in the three segments "visual", "link" and "additional"
|
||||
*
|
||||
* @param int $uri_id
|
||||
* @param int $uri_id
|
||||
* @param string $guid
|
||||
* @param array $links ist of links that shouldn't be added
|
||||
* @return array attachments
|
||||
*/
|
||||
public static function splitAttachments(int $uri_id, string $guid = '')
|
||||
public static function splitAttachments(int $uri_id, string $guid = '', array $links = [])
|
||||
{
|
||||
$attachments = ['visual' => [], 'link' => [], 'additional' => []];
|
||||
|
||||
|
@ -464,6 +465,11 @@ class Media
|
|||
$selected = '';
|
||||
|
||||
foreach ($media as $medium) {
|
||||
$medium['url'] = strtolower($medium['url']);
|
||||
if (in_array($medium['url'], $links)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = explode('/', current(explode(';', $medium['mimetype'])));
|
||||
if (count($type) < 2) {
|
||||
Logger::info('Unknown MimeType', ['type' => $type, 'media' => $medium]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue