Source for file image.php

Documentation is available at image.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Document
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * DocumentImage class, provides an easy interface to output image data
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Document
  17.  * @since       12.1
  18.  */
  19. class JDocumentImage extends JDocument
  20. {
  21.     /**
  22.      * Class constructor
  23.      *
  24.      * @param   array  $options  Associative array of options
  25.      *
  26.      * @since   12.1
  27.      */
  28.     public function __construct($options array())
  29.     {
  30.         parent::__construct($options);
  31.  
  32.         // Set mime type
  33.         $this->_mime = 'image/png';
  34.  
  35.         // Set document type
  36.         $this->_type = 'image';
  37.     }
  38.  
  39.     /**
  40.      * Render the document.
  41.      *
  42.      * @param   boolean  $cache   If true, cache the output
  43.      * @param   array    $params  Associative array of attributes
  44.      *
  45.      * @return  The rendered data
  46.      *
  47.      * @since   12.1
  48.      */
  49.     public function render($cache false$params array())
  50.     {
  51.         // Get the image type
  52.         $type JFactory::getApplication()->input->get('type''png');
  53.  
  54.         switch ($type)
  55.         {
  56.             case 'jpg':
  57.             case 'jpeg':
  58.                 $this->_mime = 'image/jpeg';
  59.                 break;
  60.             case 'gif':
  61.                 $this->_mime = 'image/gif';
  62.                 break;
  63.             case 'png':
  64.             default:
  65.                 $this->_mime = 'image/png';
  66.                 break;
  67.         }
  68.  
  69.         $this->_charset = null;
  70.  
  71.         parent::render();
  72.         return $this->getBuffer();
  73.     }
  74. }

Documentation generated on Tue, 19 Nov 2013 15:05:13 +0100 by phpDocumentor 1.4.3