I was thinking I could create an extension that would allow image embedding through Imgur. This would lighten the load on slower servers and allow for faster loading.
Imgur has an API that allows this (as long as it is not used for commercial purposes). It requires for the forum administrator to have an Imgur account and register "the application". The registration is as simple as filling in a couple inputs on Imgur's website (it is accepted automatically). It then gives you a user-id you would enter in the Flarum Admin Panel.
As an example, here is some code I found on the internet that allows you to upload Imgur with no redirects and vanilla PHP, so it could work in AJAX pretty easily.
<?php
$img=$_FILES['img'];
if(isset($_POST['submit'])) {
if($img['name']=='') {
echo "<h2>An Image Please.</h2>";
} else {
$filename = $img['tmp_name'];
$client_id="***CLIENT ID HERE***";
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));
$pvars = array('image' => base64_encode($data));
$timeout = 30;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: Client-ID ' . $client_id));
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $pvars);
$out = curl_exec($curl);
curl_close ($curl);
$pms = json_decode($out,true);
$url=$pms['data']['link'];
if($url!=""){
echo "<h2>Uploaded Without Any Problem</h2>";
echo "<img src='$url'/>";
} else {
echo "<h2>There's a Problem</h2>";
echo $pms['data']['error'];
}
}
}
?>
<form action="./" enctype="multipart/form-data" method="POST">
Choose Image: <input name="img" size="35" type="file"/><br/>
<input type="submit" name="submit" value="Upload"/>
</form>