Disable Linked Gallery Images If Mobile Browser

  1. First thing is first…
    you can use a mobile plugin to create a website especially for mobile users.
    I usally use WPtouch

  2. To check if a user is using a mobile browser / agent you can also
    use a function… that means you would need to update user agents
    from time to time…

Here is an example function from eric stokes site:
http://erikastokes.com/php/how-to-test-if-a-browser-is-mobile.php

You can embed that function in your functions.php or include it into functions.php.
Then you can check and create a conditional link for example:

<?php
if(is_mobile()) {
   echo '<a href="http://www.mobile.com">i am using mobile</a>';
}
else {
   echo '<a href="http://www.desktop.com">i am using a desktop computer</a>';
}
?>

.

Example relating to the answer you found here:

$image = wp_get_attachment_image( $id, $size, false );

// if it's set to not show the image link
if(isset($attr['link']) && ('none' == $attr['link']) && !is_mobile() ){
    // then just show the image
    echo $image;
} else {
    // else show the image wrapped in a link
    $link = wp_get_attachment_url($id);
    echo "<a href=\"$link\">$image</a>";
}

Hope this helps.
Cheers, Sagive

Leave a Comment

error code: 523