ashleydw / lightbox

A lightbox gallery plugin for Bootstrap
http://ashleydw.github.io/lightbox
MIT License
1.85k stars 1.3k forks source link

Can I grab youtube video title and place with image grabbed from youtube #285

Closed bsde1245 closed 6 years ago

bsde1245 commented 6 years ago

Can I grab youtube video title and place with image grabbed from youtube I mean along with following link

<a href="http://www.youtube.com/watch?v=k6mFF3VmVAs" data-toggle="lightbox" data-gallery="youtubevideos" class="col-sm-4">
    <img src="http://i1.ytimg.com/vi/yP11r5n5RNg/mqdefault.jpg" class="img-fluid">
</a>

Hope it is clear to you. Thanks.

ashleydw commented 6 years ago

If you know the title set data-title (see http://ashleydw.github.io/lightbox/#single-image), otherwise there's no way of getting the youtube title from the video.

bsde1245 commented 6 years ago

https://github.com/abhinayrathore/jQuery-YouTube-Popup-Player-Plugin/blob/master/jquery.youtubepopup.js

Check this out. I think someone grabbed the title here...

ashleydw commented 6 years ago

You answered your question yourself :)

Take this code and put it in the onNavigate event

https://github.com/abhinayrathore/jQuery-YouTube-Popup-Player-Plugin/blob/master/jquery.youtubepopup.js#L129

bsde1245 commented 6 years ago

Hi @ashleydw I am a newbie. Please share full code here. Thanks

bsde1245 commented 6 years ago
onNavigate: function onNavigate() {
        $.ajax({
            url: window.location.protocol + '//query.yahooapis.com/v1/public/yql',
            data: {
                q: "select * from json where url ='http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=" + id + "&format=json'",
                format: "json"
            },
            dataType: "jsonp",
            success: function (data) {
                if (data && data.query && data.query.results && data.query.results.json) {
                    YouTubeDialog.dialog({
                       title: data.query.results.json.title
                    });
                }
            }
        });
        },

Is this enough? how to get title name?