Extension:MobileDetect

This 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 , which allow users to control which content is displayed only in mobile browsers, and which content is displayed only in desktop browsers.

mobiledetect 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 desktop/full browsers. So for example:

This will not be displayed in desktop/full browsers, only in mobile browsers This will not be displayed in mobile browsers, only in desktop/full browsers

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