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.
@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 | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.
@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 | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.