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.
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?
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..
Please post a link to the album where the right click should be disabled.
It is : http://www.zofate.com/album/thumbnails.php?album=2
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
******************************************************************************/
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.?
Correct.