diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-11-22 16:32:46 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-11-22 16:32:46 +0100 |
commit | 8bf926db1926665ad8a376971a6e35f33269b8d4 (patch) | |
tree | 05889764346fd27d144075ed8e73390ffc8dde44 /index.php | |
parent | d017568a77d677e449e66d689450532a760d6f11 (diff) |
handle video/audio/text mime types
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -64,8 +64,37 @@ if (strpos($mime, 'text/gemini') === 0) { } } +else if (strpos($mime, 'text') === 0) { + echo $response->getBody(); +} + else if (strpos($mime, 'image') === 0) { - echo "<img src=\"data:{$mime};base64," . base64_encode($response->getBody()) . "\">"; + $src = "data:{$mime};base64," . base64_encode($response->getBody()); + ?> + <img src="<?php echo $src; ?>"> + <?php +} + +else if (strpos($mime, 'video') === 0) { + $src = "data:{$mime};base64," . base64_encode($response->getBody()); + ?> + <video controls> + <source src="<?php echo $src; ?>" type="<?php echo $mime; ?>"> + </video> + <?php +} + +else if (strpos($mime, 'audio') === 0) { + $src = "data:{$mime};base64," . base64_encode($response->getBody()); + ?> + <audio controls> + <source src="<?php echo $src; ?>" type="<?php echo $mime; ?>"> + </audio> + <?php +} + +else { + echo "Unhandled MIME type: $mime"; } echo "<hr>"; |