Added support for mastodon images

This commit is contained in:
Bofh 2020-10-12 22:50:58 +02:00
parent 1d835d9c0f
commit fdd10a29f1
1 changed files with 2 additions and 1 deletions

View File

@ -3,7 +3,8 @@
$url = trim($_GET['url']);
# check url matches a https://domain/storage/whatever.jpeg url for images
if (preg_match('/^https:\/\/[^\/]+\/storage\/[^\s\%]+\.(png|jpg|jpeg)(\?v=[^\&])?$/', $url)) {
if (preg_match('/^https:\/\/[^\/]+\/storage\/[^\s\%]+\.(png|jpg|jpeg)(\?v=[^\&])?$/', $url) ||
preg_match('/^https:\/\/[^\/]+\/system\/media_attachments\/[^\s\%]+\.(png|jpg|jpeg)(\?v=[^\&])?$/', $url)) {
if (preg_match('/^.*\.png(\?v=[^\&])?$/', $url))
header('Content-Type: image/png');
else if (preg_match('/^.*\.(jpg|jpeg)(\?v=[^\&])?$/', $url))