Mobile app version of vmapp.org
Login or Join
RJPawlick198

: How to tell if an incoming connection is a cellular network or not I've got a page that will be loading a bunch of fairly high resolution images, as well as a full HD video. Is there a

@RJPawlick198

Posted in: #Javascript #Mobile #Php

I've got a page that will be loading a bunch of fairly high resolution images, as well as a full HD video. Is there a way to detect if someone is using cellular on their phone vs wifi, so I can use a lower resolution version of the image, and the video?

Preferably I would like to do this in PHP, but if I can't using JavaScript is also an option.

I thought about using the User Agent string but this would only tell me if its a mobile device, not if its on wifi or cellular. I've seen several suggestions saying to use IP databases but they all seem to cost money, and it's simply out of the question to pay for the database based on current financials.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @RJPawlick198

1 Comments

Sorted by latest first Latest Oldest Best

 

@Yeniel560

You have the following general choices:


Examine the speed of the connection. You would have to devise some sort of bandwidth test that would attempt to tell whether you have a fast or slow connection. It sounds like this is what you really care about - there is no shortcut other than attempting to measure said speed.
Examine characteristics of the device. Using a number of heuristics such as size of screen, browser user agent, touch availability, etc..., you can estimate whether it's likely this is a cellular device. That of course does not tell you what kind of connection the device is on.
Examine where the connection comes from. Here you examine the origin of the client's IP address and attempt to identify it as coming from a cellular provider. This will involve building or acquiring some sort of knowledge base about IP ranges or reverse lookup domain names so you can correlate a particular IP address with a mobile provider.
You can allow the user to specify whether they want an SD or HD version of your site. Obviously, this is not automatic and therefore is not as desirable as an automatic option if you can get one to work, but is a possible fallback.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme