Displays an image file.
Command line interface
Syntax
- $ image filename
Arguments
- filename – (file) Image file to display.
Example

image.php
- <?
- require("../plugin.php");
- if (is_ajax()) {
- switch ($_POST["action"]) {
- case 'check':
- die(is_file($_POST['file']) && is_readable($_POST['file'])?"1":"-1");
- case 'fetch':
- readfile($_POST['file']);
- break;
- }
- exit;
- }
- ?>
- /**
- * Show image
- **/
- TinyShell.plugins.image = new Class({
- description: "Display image file",
- run : function(terminal, args) {
- this.t = terminal;
- if (args.length) {
- this.file = args[0];
- this.t.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=check&file="+encodeURIComponent(this.file));
- } else {
- terminal.print("image: usage: image filename");
- terminal.resume();
- }
- },
- print: function(r) {
- if (r != "1") this.t.print("image: `"+this.file+"' is not a file");
- else this.t.print("<img src='"+this.t.create_url("<?php echo $_AJAX_URL?>", "action=fetch&file="+encodeURIComponent(this.file))+"' alt='Filename: "+this.file+"' />", true);
- this.t.resume();
- }
- });