'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
'network:diaspora' => 'network:dspr', 'network:ostatus' => 'network:stat',
'network:discourse' => 'network:dscs', 'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
+ const MEDIA_NONE = 0;
+ const MEDIA_IMAGE = 1;
+ const MEDIA_VIDEO = 2;
+ const MEDIA_AUDIO = 4;
+ const MEDIA_CARD = 8;
+ const MEDIA_POST = 16;
/**
* Store engagement data from an item array
$body .= ' language_' . array_key_first($languages);
}
- if ($mediatype & 1) {
+ if ($mediatype & self::MEDIA_IMAGE) {
$body .= ' media_image';
}
- if ($mediatype & 2) {
+ if ($mediatype & self::MEDIA_VIDEO) {
$body .= ' media_video';
}
- if ($mediatype & 4) {
+ if ($mediatype & self::MEDIA_AUDIO) {
$body .= ' media_audio';
}
- if ($mediatype & 8) {
+ if ($mediatype & self::MEDIA_CARD) {
$body .= ' media_card';
}
- if ($mediatype & 16) {
+ if ($mediatype & self::MEDIA_POST) {
$body .= ' media_post';
}
public static function getMediaType(int $uri_id, int $quote_uri_id = null): int
{
$media = Post\Media::getByURIId($uri_id);
- $type = !empty($quote_uri_id) ? 16 : 0;
+ $type = !empty($quote_uri_id) ? self::MEDIA_POST : self::MEDIA_NONE;
foreach ($media as $entry) {
if ($entry['type'] == Post\Media::IMAGE) {
- $type = $type | 1;
+ $type = $type | self::MEDIA_IMAGE;
} elseif ($entry['type'] == Post\Media::VIDEO) {
- $type = $type | 2;
+ $type = $type | self::MEDIA_VIDEO;
} elseif ($entry['type'] == Post\Media::AUDIO) {
- $type = $type | 4;
+ $type = $type | self::MEDIA_AUDIO;
} elseif ($entry['type'] == Post\Media::HTML) {
- $type = $type | 8;
+ $type = $type | self::MEDIA_CARD;
} elseif ($entry['type'] == Post\Media::ACTIVITY) {
- $type = $type | 16;
+ $type = $type | self::MEDIA_POST;
}
}
return $type;