diff options
-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>"; |