Extension:MobileDetect

The MobileDetect extension detects mobile devices using PHP's HTTP_USER_AGENT. Due to the nature of the extension, it should be very compatible with both new and old versions of MediaWiki.

The extension introduces a function called, which returns true when a mobile device is detected, and false otherwise. It also introduces the and  tags, which allow users to control which content is displayed only in mobile browsers, and which content is displayed only in desktop browsers.

wfMobileDetect function
If you would like to set a default theme depending on a visitor's browser, you can add this to your LocalSettings.php:

With this code, if the visitor's browser shows a user agent from a mobile browser, the default theme will be "chick" instead of "vector". If instead the browser shows a user agent from a desktop/full browser, the default theme will be "vector" instead of "chick".

If you would like a certain extension to be excluded from loading on mobile browsers, you can add this to your LocalSettings.php:

With this code, the reCAPTCHA extension would only load on desktop/full browsers.

and tags
The MobileDetect extension also introduces the and  tags, which allow users to control which content is displayed in mobile browsers, and which in desktop/full browsers. Whatever is wrapped between tags will only be displayed in mobile browsers, and whatever is wrapped between  tags will only be displayed in desktop/full browsers. So for example:

The naming and behaviour of the and  tags follows that of the  and  tags.

nomobile and mobileonly classes
Alternatively, it is also possible to use the css classes directly:

Version 3.0

 * Version 2.1
 * By example
 * is expanded into
 * and
 * is expanded into
 * This is, what you really get:
 * For desktop:
 * For mobile devices:
 * In effect, the text is not removed, only invisible by set the css attribute  to.
 * This is, what you really get:
 * For desktop:
 * For mobile devices:
 * In effect, the text is not removed, only invisible by set the css attribute  to.
 * For mobile devices:
 * In effect, the text is not removed, only invisible by set the css attribute  to.
 * In effect, the text is not removed, only invisible by set the css attribute  to.
 * In effect, the text is not removed, only invisible by set the css attribute  to.


 * Version 3.0
 * In this fork this is not handled by css gimmik, but text is really removed by the parser.
 * You set the tags:
 * a)
 * b)
 * You get:
 * For desktop:
 * a)
 * b)
 * b)
 * Now you can do i.e. the following:
 * Your  page:


 * Your  page:


 * Change in the file  the functions   and


 * into:


 * or better: