• 0

PHP image show/hide on different media types


Go to solution Solved by threetonesun,

Question

Kalint

Is there a way to say, if desktop show this image but if mobile hide this image?

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
threetonesun

Is there a way to say, if desktop show this image but if mobile hide this image?

 

Sure, give every image you want to hide the same class, use a media query to hide it when the screen resolution drops below a certain point.

  • Like 1
Link to post
Share on other sites
  • 0
ILikeTobacco

Is there a way to say, if desktop show this image but if mobile hide this image?

Yes, use CSS stylesheets. You can display a different stylesheet based on the platform

 

http://detectmobilebrowsers.com/

 

Don't know if those work but its the basic idea. Have two stylesheets. Show one with images if its desktop browser and another if mobile

Link to post
Share on other sites
  • 0
NJ Louch

Screen resolution?  Use CSS and target towards mobiles.  Much more elegant!

Link to post
Share on other sites
  • 0
threetonesun

Screen resolution?  Use CSS and target towards mobiles.  Much more elegant!

 

Eh? Based on what. Media queries are CSS. You can get more specific with orientation and device ratio, if you want, but in the end resolution will get you where you need to be.

 

For reference, here's a very detailed guide to targeting every Apple i-device with media queries:

http://www.stephentgilbert.com/mediaqueries/

 

Goes slightly overboard, depending on the situation. For a very simple optimization, you might just want a killswitch on some images when the screen size is < 1024px.

Link to post
Share on other sites
  • 0
NJ Louch

Sorry pal, am half asleep, I read "query" as "jQuery"

  • Like 1
Link to post
Share on other sites
  • 0
ILikeTobacco

I suppose the next question is, what is the reasoning. If the purpose is to save bandwidth for mobile devices, the resolution of newer devices would now result in wasting bandwidth.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.