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 "nomobile" and "mobileonly" tags, parser functions and CSS classes 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 parser functions
The MobileDetect extension also introduces the  and   parser functions, which work exactly like the  and  tags, with the difference that their content gets parsed so they can contain stuff like   and be used in templates.

However, they don't render all multi-line content correctly, so use them mostly for inline content.

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