# Detect mobile from hubl

**URL:** <https://community.hubspot.com/t/detect-mobile-from-hubl/10463>\
**Category:** CMS Development\
**Created:** [October 4, 2018, 11:00am UTC](https://community.hubspot.com/t/detect-mobile-from-hubl/10463 "2018-10-04T11:00:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MartinsC](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/martinsc/32/31639_2.png) [@MartinsC](https://community.hubspot.com/u/MartinsC)\
**Post date:** [October 4, 2018, 11:00am UTC](https://community.hubspot.com/t/detect-mobile-from-hubl/10463/1 "2018-10-04T11:00:08Z")

</div>

Hi there.

Is there any possibility to detect mobile devices on the hubl (server) side? Like in WordPress, there’ s function wp\_is\_mobile() which returns true or false. Or php library mobiledetect which does the same thing.

I am creating a custom module, a hero block and it should follow this logic:

If desktop → show video as background

Else → show image as background

I did not see anything like this in documentation, just wondering if it is possible. If not, will have to do it with javascript.

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [October 4, 2018, 5:51pm UTC](https://community.hubspot.com/t/detect-mobile-from-hubl/10463/2 "2018-10-04T17:51:55Z")

</div>

@MartinsC - If you really need to do it in HUBL and you’re up to the task, you can use the request headers hubl to detect the user agent and then create a switch to show relevant content:

`{{request.headers['user-agent']}}`

However, it’s much easier to create both headers and just hide the video background section on mobile and show that version on desktop using CSS media queries

* * *

If this answer helped, please, mark as solved 😄

* * *

[tim@belch.io](mailto:tim@belch.io) | [forms.belch.io](https://forms.belch.io) | Design your own Beautiful HubSpot Forms; No coding necessary.

Drop by and say Hi to me [on slack](http://slack.belch.io/).
