Skip to content
Grav 2.0 is officially stable. Read the announcement →
Plugins

jQuery Modal Video Plugin not working in last grav version

Solved by pamtbaau View solution

Started by Pedro M 5 years ago · 3 replies · 1065 views
5 years ago

Hi.

I use jQuery Modal Video Plugin in the site Hukawati to show some video in modal popup.
So far I have not had problems, but since the last Grav update in the modal window the video appears as Not available, while if I copy the url of the video and show it in a separate window, it does work.
This is the code I use for the modular page that the videos load:

TWIG
{% block stylesheets %}
    {% do assets.addCss('theme://css/modal-video.min.css') %}
{% endblock %}
{% block javascripts %}
    {% do assets.addJs('theme://js/modal-video.min.js', {group:'bottom'}) %}
     {% do assets.addJs('theme://js/jquery-modal-video.min.js', {group:'bottom'}) %}

{% endblock %}
{% block assets deferred %}
    {{ assets.css()|raw }}
    {{ assets.js()|raw }}
{% endblock %}
<div class="modular-row video-list {{ page.header.class }}" {% if page.header.bg_color %}style="background-color:{{page.header.bg_color}};"{% endif %}>
    {{ content|raw }}  
    <div class="videos">
        {% for video in page.header.videos %}
        <div class="video">
            {% if video.title %}<p><strong>{{video.title|raw}}</strong></p>{% endif %}
            {% if video.description %}<p>{{video.description|raw}}</p>{% endif %}
            <a href="#" class="js-modal-video" data-video-id="{{ video.id }}">
                <div class="video-thumbnail">
                    <img src="https://i.ytimg.com/vi/{{ video.id|e }}/hqdefault.jpg" alt="{{ video.title|e }}" /> 
                </div>
            </a>
        </div>
        {% endfor %}
    </div>
</div>
{% block bottom %}
    {{ assets.js('bottom')|raw }}
    <script type="text/javascript">
        $(".js-modal-video").modalVideo({channel:'youtube'});
    </script>
{% endblock %}

This code has been working perfectly so far.
What happened in the latest Grav update to prevent this from working?

Thanks in advance

5 years ago

It's some combination of embed URL params. Maybe YT changed something on their end.
This works - https://www.youtube.com/embed/ett71FNSD2s
This doesn't - https://www.youtube.com/embed/ett71FNSD2s?autoplay=1&cc_load_policy=1&color=null&controls=1&disablekb=0&enablejsapi=0&end=null&fs=1&h1=null&iv_load_policy=1&listType=null&loop=0&modestbranding=null&mute=0&origin=null&playlist=null&playsinline=null&rel=0&showinfo=1&start=0&wmode=transparent&theme=dark&nocookie=false

5 years ago

Hello there.
Sure enough, I have modified the script that calls the modal dialog, removing all references to null (https://github.com/appleple/modal-video/issues/73#issuecomment-941040075), and it is working fine.
The script looks as follows:

HTML
<script type="text/javascript">
        $(".js-video-button").modalVideo({
            channel: 'youtube',
            youtube: {
                autoplay: 1,
                cc_load_policy: 1,
                controls: 1,
                disablekb: 0,
                enablejsapi: 0,
                fs: 1,
                iv_load_policy: 1,
                loop: 0,
                rel: 0,
                showinfo: 1,
                start: 0,
                wmode: 'transparent',
                theme: 'dark'}
            });
    </script>

Thanks for your cooperation.

👍 1

Suggested topics

Topic Participants Replies Views Activity
Plugins · by Rene, 1 week ago
2 75 1 week ago
Plugins · by Xavier, 4 weeks ago
2 81 4 weeks ago
Plugins · by Luka Prinčič, 7 years ago
3 1208 1 month ago
Plugins · by Sebastian van de Meer, 1 month ago
1 75 1 month ago
Plugins · by PIERROT Alain, 2 months ago
3 99 2 months ago