Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #303834

    Zeshan
    Member

    Hi there,

    Thanks for writing in!

    The provided code works with X Shortcode, as you are using Cornerstone, please use following code instead:

    // Liking Portfolio Items to Featured Image URL to Open Them in a Lightbox
    // =============================================================================
    
    add_filter( 'post_type_link', 'x_remap_portfolio_to_page', 10, 4);
    function x_remap_portfolio_to_page($post_link, $post, $leavename, $sample) {
    
      if ( 'x-portfolio' == $post->post_type ) {
        return $image_link = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
      }
    
      return $post_link;
    }
    
    add_action('wp_footer', 'enqueue_lightbox_script');
    function enqueue_lightbox_script() {
      echo '
        <script type="text/javascript" src="' . home_url() . '/wp-content/plugins/cornerstone/assets/js/dist/site/vendor-ilightbox.min.js"></script>
        <script>jQuery(document).ready(function($) {
           $(\'.page-template-template-layout-portfolio .entry-featured .entry-thumb\').click(function(e) {
              e.preventDefault();
           });
        });
        jQuery(document).ready(function(){jQuery(".x-portfolio .entry-featured a").iLightBox({skin: "light",linkId: "gallery-image",overlay: {opacity: 0.875,blur: true},styles: {prevScale: 0.75,prevOpacity: 0.75,nextScale: 0.75,nextOpacity: 0.75},path: "horizontal",controls: {thumbnail: false}});});
      </script>';
    }
    

    Hope this helps. 🙂

    Thank you.

    #303885

    gmilne
    Participant

    Hi,

    I’ve added the code above to the functions.php file of my child theme but still nothing happens when clicking on the portfolio items.

    #304379

    Paul R
    Moderator

    Hi,

    I was able to fix it by changing .x-portfolio .entry-title a to .x-portfolio .entry-featured a

    Kindly check on your end.

    http://janinevanmoosel.co.uk/portfolio/

    Thanks

    #602637

    jeetpatel88
    Participant

    Hello, I need to build portfolio with lightbox too. I read carefull instructions, but You use
    <script type=”text/javascript” src=”‘ . home_url() . ‘/wp-content/plugins/x-shortcodes/js/dist/site/vendor-ilightbox.min.js”></script>
    but I have not this script in my folders. How can I make lightbox without this plugin?

    #602661

    Christopher
    Moderator

    Hi there,

    Please load the script from following file :
    wp-content/plugins/cornerstone/assets/js/dist/site/vendor-ilightbox.min.js

    Thanks.

    #602682

    jeetpatel88
    Participant

    Thank you!

    #602697

    Christopher
    Moderator

    You’re welcome.

    #664835

    nachoowl
    Participant

    Hi
    i´ve tried everything to set the portfolio items to a lightbox, as you tell in the posts step by step. no chance

    using integrity, and cannot set the lightbox

    #664836

    Christopher
    Moderator

    Hi there,

    Please open a new topic and provide us with URL, login and FTP credentials.
    Please provide us with a link to this thread as well.

    Thanks.