Difference between revisions of "JBrowser/isViewable"
From Joomla! Documentation
< API16:JBrowser
(New page: ===Description===
Determines if a browser can display a given MIME type.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JBrowser/isViewable|Edit Des...) |
m (preparing for archive only) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
Determines if a browser can display a given MIME type. | Determines if a browser can display a given MIME type. | ||
− | |||
− | |||
− | |||
− | + | ||
+ | <! removed transcluded page call, red link never existed > | ||
===Syntax=== | ===Syntax=== | ||
Line 75: | Line 73: | ||
</source> | </source> | ||
− | + | ||
− | + | <! removed transcluded page call, red link never existed > | |
− | < | ||
− | |||
===Examples=== | ===Examples=== | ||
− | + | === Code Examples === | |
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=isViewable | category=isViewable | ||
category=JBrowser | category=JBrowser | ||
− | + | namespace=CodeExample | |
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Latest revision as of 20:20, 24 March 2017
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Determines if a browser can display a given MIME type.
<! removed transcluded page call, red link never existed >
Syntax[edit]
isViewable($mimetype)
Parameter Name | Default Value | Description |
---|---|---|
$mimetype | $mimetype The MIME type to check. |
Returns[edit]
boolean True if the browser can display the MIME type.
Defined in[edit]
libraries/joomla/environment/browser.php
Importing[edit]
jimport( 'joomla.environment.browser' );
Source Body[edit]
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 transcluded page call, red link never existed >
Examples[edit]
Code Examples[edit]