Different image for mobile and desktop

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
durangod
Posts: 5
Joined: 25 Mar 2024, 03:55

Different image for mobile and desktop

Post by durangod »

Hi,

I wanted to show a different (smaller) image for mobile than for desktop. i poked around a bit and found the php functions that handle the image config vars but i didnt want to mess with that. I also looked at adding media to the css but that was a fuss as well. :)

So i just added this to the config file (i am aware it only checks for android) just wanted to share. If anyone has a better way please share. :)

Just FYI, my full image is 500x120 and the mobile image is half of that 250x60 and both look good...

Code: Select all

//check for android 
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($ua,'android') !== false && strpos($ua,'mobile') !== false) 
{
    // smaller mobile size
    $g_logo_image  = 'images/mobile_logo.png';
    
}else{
    
      //full size desktop version
      $g_logo_image	= 'images/full_logo.png'; 
      
     }

Post Reply