neon-jungle / wagtail-videos

Videos for Wagtail CMS, including transcoding
BSD 3-Clause "New" or "Revised" License
65 stars 57 forks source link

Selected video thumbnail not showing in streamfields #81

Open quaintjames opened 3 years ago

quaintjames commented 3 years ago

When selecting a video the first time around, the video thumbnail is shown next to the video selection button image , however after publishing and revisiting the page, the thumbnail is no longer next to the 'choose a video' button. image

The video has been selected and the database information is correct, but the video thumbnail is not fetched and the buttons are reset to their original state, which may leave users thinking that there is no video uploaded.

tr-j commented 3 years ago

I am having the same issue. The value of the video is available in the hidden input field after rendering, but doesn't seem to be available when the chooser is being created. This workaround corrects the preview image for me after rendering, but it doesn't fix the underlying missing value.

wagtailvideos/static/wagtailvideos/js/video-chooser.js (line 8, after variable declarations):

document.addEventListener('DOMContentLoaded', event => {
    var input = $('#' + id);
    let call_url = window.chooserUrls.videoChooser + input.val();
    $.ajax(call_url).done(function(data) {
        let videoData = data.result
        input.val(videoData.id);
                previewVideo.attr({
                    src: videoData.preview.url,
                    alt: videoData.title
                });
                chooserElement.removeClass('blank');
                editLink.attr('href', videoData.edit_link);
    });
})