Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Add video support #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pgwslideshow.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
filter: alpha(opacity=60);
}

.pgwSlideshow .ps-list li img {
.pgwSlideshow .ps-list li img,
.pgwSlideshow .ps-list li video {
display: block;
border: 1px solid #777;
width: 80px;
Expand Down Expand Up @@ -207,4 +208,4 @@
.pgwSlideshow.narrow .ps-caption {
font-size: 0.8rem;
padding: 8px;
}
}
16 changes: 14 additions & 2 deletions pgwslideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@

// Update the current height
var updateHeight = function(height, animate) {

// Check maxHeight
if (pgwSlideshow.config.maxHeight) {
if (height + pgwSlideshow.plugin.find('.ps-list').height() > pgwSlideshow.config.maxHeight) {
Expand Down Expand Up @@ -224,6 +223,8 @@
currentElement.html('<img src="' + element.image + '" alt="' + (element.title ? element.title : '') + '">');
} else if (element.thumbnail) {
currentElement.html('<img src="' + element.thumbnail + '" alt="' + (element.title ? element.title : '') + '">');
} else if (element.video) {
currentElement.html('<video controls><source src="' + element.video + '" type="video/mp4">Your browser does not support the video tag.</video>');
}

if (element.link) {
Expand Down Expand Up @@ -307,6 +308,11 @@
element.image = elementImage;
}

var elementVideo = obj.find('video source').attr('src');
if ((typeof elementVideo != 'undefined') && (elementImage != '')) {
element.video = elementVideo;
}

// Get title
var elementTitle = obj.find('img').attr('alt');
if ((typeof elementTitle != 'undefined') && (elementTitle != '')) {
Expand Down Expand Up @@ -375,7 +381,13 @@
}

// Set the container height
var maxHeight = pgwSlideshow.plugin.find('.ps-current .elt_' + element.id + ' img').height();
var maxHeight;
if(element.video){
maxHeight = pgwSlideshow.plugin.find('.ps-current .elt_' + element.id + ' video').height();
maxHeight += 15;
}else{
maxHeight = pgwSlideshow.plugin.find('.ps-current .elt_' + element.id + ' img').height();
}
updateHeight(maxHeight, true);

return true;
Expand Down