Actions

API16

JBrowser/isViewable

From Joomla! Documentation

< API16:JBrowser
Revision as of 21:51, 12 May 2013 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Determines if a browser can display a given MIME type.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

isViewable($mimetype)
Parameter Name Default Value Description
$mimetype $mimetype The MIME type to check.

Returns

boolean True if the browser can display the MIME type.

Defined in

libraries/joomla/environment/browser.php

Importing

jimport( 'joomla.environment.browser' );

Source Body

public function isViewable($mimetype)
{
        $mimetype = strtolower($mimetype);
        list($type, $subtype) = explode('/', $mimetype);
 
        if (!empty($this->_accept)) {
                $wildcard_match = false;
 
                if (strpos($this->_accept, $mimetype) !== false) {
                        return true;
                }
 
                if (strpos($this->_accept, '*/*') !== false) {
                        $wildcard_match = true;
                        if ($type != 'image') {
                                return true;
                        }
                }
 
                /* image/jpeg and image/pjpeg *appear* to be the same
                * entity, but Mozilla doesn't seem to want to accept the
                * latter.  For our purposes, we will treat them the
                * same.
                */
                        if ($this->isBrowser('mozilla') &&
                        ($mimetype == 'image/pjpeg') &&
                        (strpos($this->_accept, 'image/jpeg') !== false)) {
                                return true;
                        }
 
                if (!$wildcard_match) {
                        return false;
                }
        }
 
        if (!$this->hasFeature('images') || ($type != 'image')) {
                return false;
        }
 
        return (in_array($subtype, $this->_images));
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />