• 0

PHP image show/hide on different media types


Question

6 answers to this question

Recommended Posts

  • 0

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.

Link to comment
Share on other sites

  • 0

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 comment
Share on other sites

  • 0

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 comment
Share on other sites

  • 0

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 comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.