Disable Right Click for a Specific Album Disable Right Click for a Specific Album
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Disable Right Click for a Specific Album

Started by mr.bena, April 02, 2012, 03:22:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mr.bena

Hi, I want to set one of the albums in my gallery to be right click disable. I know there is overlay image functionality, but this function works for the whole gallery. I want my users to see the pictures but not able to save those pictures from my one special album.

I do hope this is possible by putting some extra code in "displayimage.php".  For example..

if album id equal to 3 (album=3)
{
   HTML Disable right click code.
}

I do not know how to write this code for displayimage.php. Please help me...

Ben.

Αndré

Neither disabling the right click nor the transparent overlay will prevent experienced users to save your pictures. However, what's your preferred solution if you want to apply it anyway?

mr.bena

I understand, Andre..  However, I want to discourage the newbies at least. In my case, Overlay will not work because I use Lightbox Plugin which disables the functionality of Image Overlay. So, I have no choice than Right Click Disable functionality here..

Αndré

Please post a link to the album where the right click should be disabled.


Αndré

Copy this to your theme's theme.php file:
/******************************************************************************
** Section <<<theme_javascript_head>>> - START
******************************************************************************/
// Function for the JavaScript inside the <head>-section
function theme_javascript_head()
{
    global $JS, $LINEBREAK;

    $return = '';
   
    // Check if we have any variables being set using set_js_vars function
    if (!empty($JS['vars'])) {
        // Convert the $JS['vars'] array to json object string
        $json_vars = json_encode($JS['vars']);
        // Output the json object
        $return = <<< EOT
<script type="text/javascript">
/* <![CDATA[ */
    var js_vars = $json_vars;
/* ]]> */
</script>

EOT;
    }

    // Check if we have any js includes
    if (!empty($JS['includes'])) {
        // Bring the jquery core library to the very top of the list
        if (in_array('js/jquery-1.3.2.js', $JS['includes']) == TRUE) {
            $key = array_search('js/jquery-1.3.2.js', $JS['includes']);
            unset($JS['includes'][$key]);
            array_unshift($JS['includes'], 'js/jquery-1.3.2.js');
        }
        $JS['includes'] = CPGPluginAPI::filter('javascript_includes',$JS['includes']);
        // Include all the files which were set using js_include() function
        foreach ($JS['includes'] as $js_file) {
            $return .= js_include($js_file, true) . $LINEBREAK;
        }
    }
   
    // Disable right mouse button (context menu)
    global $album;
    if ($album == 2) {
        $return .= <<< EOT
<script type="text/javascript">$(document).ready(function(){
  document.oncontextmenu = function() {return false;};

  $(document).mousedown(function(e){
    if( e.button == 2 ) {
      return false;
    }
    return true;
  });
});
</script>
EOT;
    }
   
    return $return;
}
/******************************************************************************
** Section <<<theme_javascript_head>>> - END
******************************************************************************/

mr.bena

Thank you so much... Andre. So, if I would like to set another album, will it work if I just replace the no. 2 in "if ($album == 2)" with another album ID such as 3, 5, 7 etc.?

Αndré