you could use
mime_content_type along with a set of allowed types to determine how it's embedded in the post
video types are usually prefixed with "video/" and image types with "image/" which lets you almost be lazy with insertions, there's some exceptions where it uses an "application/" prefix in which case you should add some kinda exception, MDN maintains a list of common ones
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_typesthis is the code i have in the chat for inserting the link with the appropriate bbcode
if(fileInfo.type.indexOf('image/') === 0) {
insertText = '[img]' + fileInfo.url + '[/img]';
thumb.style.backgroundImage = 'url(\'%\')'.replace('%', fileInfo.thumb);
thumb.classList.remove('hidden');
} else if(fileInfo.type.indexOf('audio/') === 0) {
insertText = '[audio]' + fileInfo.url + '[/audio]';
} else if(fileInfo.type.indexOf('video/') === 0) {
insertText = '[video]' + fileInfo.url + '[/video]';
}
fileInfo.type here is from json i have returned when an upload finishes successfully, for example;
{
"id": "aWG2NDmxz4GapUEEgVE1gm07RMX2d97l",
"url": "//i.flashii.net/aWG2NDmxz4GapUEEgVE1gm07RMX2d97l",
"urlf": "//eeprom.flashii.net/uploads/aWG2NDmxz4GapUEEgVE1gm07RMX2d97l",
"thumb": "//i.flashii.net/aWG2NDmxz4GapUEEgVE1gm07RMX2d97l.t",
"name": "1581826672-oeqAZPM.png",
"type": "image/png",
"size": 1228757,
"user": 1,
"hash": "fc9e98c6f93c1d39266e20dd8fc39a7004fc6c7a3ebf572e32aaa8398576d781",
"created": "2020-03-02T02:06:22+00:00",
"accessed": "2020-03-02T02:56:46+00:00",
"expires": "2021-03-02T08:56:46+00:00",
"deleted": null,
"dmca": null
}