Support » Plugin: Easy FancyBox » Disable plugin certain images

  • Resolved phineas137

    (@phineas137)


    Hi!
    Is there any php code to desactivate the plugin in certain images? I insert the images with the ACF plugin and I want to disable Easy Fancy Box for non registered users.
    Thx!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author RavanH

    (@ravanh)

    Hi, so do you wish to disable the light box for certain images or for certain visitors?

    In the first case (images) you can give the image link in question a class=”nolightbox” attribute. This will prevent FancyBox from binding itself to the media link.

    In the second case (users) you might be able to write some PHP that adds this class only for anonymous visitors using if ( !is_user_logged_in() ) { ... } for example. See https://developer.wordpress.org/reference/functions/is_user_logged_in/

    Thread Starter phineas137

    (@phineas137)

    Thanks for your reply RavanH. I used the attribute, the FancyBox don’t work but when I click on the image it’s open the image on path. This is the code I’m using;

    <?php 
    $image = get_field('logo_game');
    
    if( !empty($image) ):
    
    	// vars
    	$url = $image['url'];
    	$title = $image['title'];
    	$alt = $image['alt'];
    	$caption = $image['caption'];
    
    	// thumbnail
    	$size = 'large';
    	$thumb = $image['sizes'][ $size ];
    	$width = $image['sizes'][ $size . '-width' ];
    	$height = $image['sizes'][ $size . '-height' ];
    
    	if( $caption ): ?>
    
    		<div class="wp-caption">
    
    	<?php endif; ?>
    
    	<a class="nolightbox" href="<?php echo $url; ?>" title="<?php echo $title; ?>">
    
    		<img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" width="<?php echo $width; ?>" height="<?php echo $height; ?>" />
    
    	</a>
    
    	<?php if( $caption ): ?>
    
    			<p class="wp-caption-text"><?php echo $caption; ?></p>
    
    		</div>
    
    	<?php endif; ?>
    
    <?php endif; ?>
    • This reply was modified 2 years, 11 months ago by phineas137.
    Plugin Author RavanH

    (@ravanh)

    So I gather you want FancyBox to work for logged in users and not for anonymous visitors?

    Then you could try replacing the line

    
    <a class="nolightbox" href="<?php echo $url; ?>" title="<?php echo $title; ?>">
    

    with

    
    <a <?php if ( !is_user_logged_in() ) echo 'class="nolightbox"'; ?> href="<?php echo $url; ?>" title="<?php echo $title; ?>">
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disable plugin certain images’ is closed to new replies.