mirror of
https://github.com/friendica/friendica
synced 2025-04-22 09:10:10 +00:00
Improved mimeType detection and setting of the "type" field
This commit is contained in:
parent
0b239f368b
commit
b65f73e348
3 changed files with 104 additions and 38 deletions
|
@ -123,21 +123,7 @@ class Processor
|
|||
}
|
||||
|
||||
$data = ['uri-id' => $uriid];
|
||||
|
||||
$filetype = strtolower(substr($attachment['mediaType'], 0, strpos($attachment['mediaType'], '/')));
|
||||
if ($filetype == 'image') {
|
||||
$data['type'] = Post\Media::IMAGE;
|
||||
} elseif ($filetype == 'video') {
|
||||
$data['type'] = Post\Media::VIDEO;
|
||||
} elseif ($filetype == 'audio') {
|
||||
$data['type'] = Post\Media::AUDIO;
|
||||
} elseif (in_array($attachment['mediaType'], ['application/x-bittorrent', 'application/x-bittorrent;x-scheme-handler/magnet'])) {
|
||||
$data['type'] = Post\Media::TORRENT;
|
||||
} else {
|
||||
Logger::info('Unknown type', ['attachment' => $attachment]);
|
||||
return;
|
||||
}
|
||||
|
||||
$data['type'] = Post\Media::UNKNOWN;
|
||||
$data['url'] = $attachment['url'];
|
||||
$data['mimetype'] = $attachment['mediaType'];
|
||||
$data['height'] = $attachment['height'] ?? null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue