This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Tagged: ,

Link to an open lightbox?

  • Creator
    Topic
  • #6669
    damian
    Participant

    I’m creating lots of videos on my site and want to link to them in emails.

    Is it possible for my link to a post that contains a video in a light box to also open up the light box? So that it starts playing straight away and when the light box is closed, the user is on the page that I sent them to.

    If I can’t do this, then I’ll probably have to replace all of the lightbox videos with embedded videos which autoplay. That’s the only way I can see of preventing the user from having to click again (after clicking the link). I would really rather keep the light box set up if I can though.

    I mentioned this to a friend who gave me this bit of code:

    ********************
    You could try something like:

    $(function(){
    if (document.location.href.indexOf(‘autoplay=true’)!=-1) {
    $(‘.video’).click();
    }
    });

    and then use this link in your email:

    http://www.gingermagic.com/gingermagictv/impossible-object-wedding-magician-effect/?autoplay=true

    It’s not terribly elegant but should do the trick.

    *************************

    But I don’t really know what to do with that I don’t want to start playing with the code of the theme.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #6679
    Jason Bobich
    Keymaster

    Hello,

    I think what you’re asking could actually get quite complicated. What you’re friend is suggesting is definitely a good approach, but it’s really only the start. He’s basically just showing with javascript, if there is an “autoplay” parameter passed through the URL, do something.

    To start implementing your custom javascript, you wouldn’t need to touch any files of the theme. You’d want enqueuing your own javascript from your Child theme’s functions.php.

    If you check out prettyPhoto’s API documentation (which is the lightbox plugin the theme uses), they do have some functions you can use to actually trigger lightbox popups directly. These are the things you’ll want to look at after looking for your “autoplay” parameter being passed through the URL.

    http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/documentation/

    (Look at Public API section at the bottom)

    #6680
    damian
    Participant

    The video’s already ‘autoplay’ as soon as the light box opens, so all I need is a way to trigger the lightbox to open from an external link.

    Obviously sounds easier than it is. 🙁

    I can’t see anything on the page you linked to that achieves it.

    #6682
    Jason Bobich
    Keymaster

    The videos in prettyPhoto (YouTube and Vimeo) already play automatically when the lightbox opens up. So, what you need to do with your “autoplay” paramater is open the lightbox, and that’s what I think one of those functions I linked you to do.

    jQuery(document).ready(function($) {
    	if (document.location.href.indexOf('autoplay=true') != -1)
    	{
    			$.prettyPhoto.open( ... );
    	}
    });

    Where you’ll have to get creative, is telling prettyPhoto which video to open up when you link to the given page. Definitely not a simple task. You’ll need to some javascript knowledge for sure. Maybe you could pass the video URL through the URL, as well, and pass that through to prettyPhoto’s open method.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The forum ‘Swagger Responsive WordPress Theme’ is closed to new topics and replies.