Jump to content



Photo

PHP image show/hide on different media types

Answered Go to the full post

  • Please log in to reply
6 replies to this topic

#1 Kalint

Kalint

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 16-January 07

Posted 29 July 2013 - 18:39

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



Best Answer threetonesun , 29 July 2013 - 19:03

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.

Go to the full post



#2 ILikeTobacco

ILikeTobacco

    Neowinian Senior

  • Joined: 08-July 10

Posted 29 July 2013 - 18:40

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



#3 threetonesun

threetonesun

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 26-February 02

Posted 29 July 2013 - 19:03   Best Answer

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.



#4 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 1
  • Joined: 14-January 03

Posted 29 July 2013 - 19:12

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



#5 threetonesun

threetonesun

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 26-February 02

Posted 29 July 2013 - 19:17

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.stephentg...m/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.



#6 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 1
  • Joined: 14-January 03

Posted 29 July 2013 - 19:26

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



#7 ILikeTobacco

ILikeTobacco

    Neowinian Senior

  • Joined: 08-July 10

Posted 30 July 2013 - 02:08

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.





Click here to login or here to register to remove this ad, it's free!