• Resolved jebus

    (@jebus)


    I’m trying to use this to generate image links to various videos related to individual posts with a custom field.

    If I create the shortcode manually and embed it in the post, it shows the image link. When I click on it, it opens the correct video in a new tab. I close that tab and the same video is open in a lightbox.

    But what I need to do is use this in a template with the do_shortcode. I’ve tried various methods, but nothing at all is returned, no even an error. This is true even if I hardcode the shortcode with the correct values in the template.

    Is there some reason the shortcode won’t work in a template with do_shortcode, and does it opening in a new tab suggest anything?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support mbrsolution

    (@mbrsolution)

    Hi, can you share the code you are currently testing in your site?

    Thank you

    Thread Starter jebus

    (@jebus)

    Sure. Thanks for responding.

    Here’s the shortcode:

    [video_lightbox_youtube video_id="cMFJzMe4ZQ8&t=4s" width="800" height="600" anchor="https://dev.letgrow.org/wp-content/themes/let-grow/images/watch-video.png"]

    Here it is in action. See the “Watch the video” image link right below the embed.

    https://dev.letgrow.org/program/let-grow-project/

    Thread Starter jebus

    (@jebus)

    There are some console errors too, but I honestly have no idea what they mean or if they’re even relevant.

    Plugin Support mbrsolution

    (@mbrsolution)

    Hi, here is a sample php code you might like to try. This was submitted by someone in the support forum.

    <?php echo do_shortcode('[video_lightbox_youtube video_id="" width="640" height="480" alt="alt text for the image" auto_thumb="1"]
    ');?>

    Let me know if it works for you.

    Kind regards

    • This reply was modified 6 years, 8 months ago by mbrsolution.

    I have the do_shortcode working but…

    [video_lightbox_youtube video_id=”ay_jN3KHp5c” width=”640″ height=”480″ anchor=”test”]

    results in both the modal opening and a tab which loads the youtube video page.

    Inspecting the code it appears that there is an onclick that if removed allows the link to open the video to open in the modal as expected.

    This fails (opens both modal and new tab)
    <a id="5acfa38cbb499" rel="wp-video-lightbox" href="https://www.youtube.com/watch?v=fHGUl7ce_sE&width=640&height=480" title="" onclick="javascript:window.open('https://www.youtube.com/watch?v=ay_jN3KHp5c&width=640&height=480'); return false;">test 1111</a>

    This works as expected
    <a id="5acfa38cbb499" rel="wp-video-lightbox" href="https://www.youtube.com/watch?v=ay_jN3KHp5c&width=640&height=480" title="">test 1111</a>

    BTW dropping the link without the onclick just results in teh onclick being added, so adding this link to a page…

    <a id="5acfa38cbb499" rel="wp-video-lightbox" href="https://www.youtube.com/watch?v=ay_jN3KHp5c&width=640&height=480" title="">test 1111</a>

    becomes…

    <a id="5acfa38cbb499" rel="wp-video-lightbox" href="https://www.youtube.com/watch?v=fHGUl7ce_sE&width=640&height=480" title="" onclick="javascript:window.open('https://www.youtube.com/watch?v=ay_jN3KHp5c&width=640&height=480'); return false;">test 1111</a>

    any idea why this started happening?

    • This reply was modified 6 years, 7 months ago by phillipswdc.

    this seemed to fix the issue but it feels wrong!!
    <script>
    setTimeout(function(){
    jQuery(‘a[rel=”wp-video-lightbox”]’).prop(‘onclick’,null);
    },1000);
    </script>

    Thread Starter jebus

    (@jebus)

    I should have updated this earlier, but my issue was me being dumb and not realizing that I had some jQuery that was opening all external links in a new tab. So, probably unrelated to your issue.

    I don’t have that onClick in my link that you get. All I have is an href, url, rel and blank title. Is that standard with this plugin, or is that a result of a setting? I wouldn’t think that onClick would be there since I’m assuming they do the jQuery in the background based on the rel.

    Plugin Support mbrsolution

    (@mbrsolution)

    Hi @jebus, is your issue now resolved?

    @phillipswdc, can you start a new support thread. You can referenced this thread if you like.

    Thank you

    Thread Starter jebus

    (@jebus)

    Yes, thanks. I should have updated.

    Plugin Support mbrsolution

    (@mbrsolution)

    Thank you @jebus for letting me know. I will mark this support thread as resolved.

    Kind regards.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Shortcode opens both in new tab and lightbox, do_shortcode() doesn’t work at all’ is closed to new replies.