For context, this is just a website that displays a thumbnail gallery linking to larger photos/videos.
When the thumbnails of photos are opened there is no problem. The thumbnails with a video attached to them look identical to the photo thumbnail only until the video thumbnail is clicked and the video will not load. Reference the HTML(first block) & javascript(second block) code below, any help would be greatly appreciated, this is my own personal project and I have been stuck for a couple days lol. if there any other information required, please do not hesitate to ask
This what happens when the thumbnail with the video is clicked but the video DOES NOT PLAY :(
<!-- code below is the PHOTO block of code ! -->
<article class="thumb">
<a href="images/fulls/21.jpg" class="image">
<img src="images/thumbs/21.jpg" class="image" alt="" /></a>
<h2> Cmon mayne</h2>
<p>Photoshoot with Myles Jay </p>
</article>
<!-- code below is the VIDEO block of code ! -->
<article class="thumb">
<a href="images/fulls/16.mp4" type="video/mp4" video
src="images/fulls/16.mp4" class="image">
<img src="images/thumbs/ab22.jpg" class="image" alt="" />
</a> <h2> Getting to the work</h2>
<p>Photoshoot with Myself </p>
</article>
// Main.
var $main = $('#main');
// Thumbs.
$main.children('.thumb').each(function() {
var $this = $(this),
$image = $this.find('.image'), $image_img = $image.children('img'),
x;
// No image? Bail.
if ($image.length == 0)
return;
// Image.
// This sets the background of the "image" <span> to the image pointed to by its child
// <img> (which is then hidden). Gives us way more flexibility.
// Set background.
$image.css('background-image', 'url(' + $image_img.attr('src') + ')');
// Set background position.
if (x = $image_img.data('position'))
$image.css('background-position', x);
// Hide original img.
$image_img.hide(); });
// Poptrox.
$main.poptrox({
baseZIndex: 20000,
caption: function($a) {
var s = '';
$a.nextAll().each(function() {
s += this.outerHTML;
});
return s;
},
fadeSpeed: 300,
onPopupClose: function() { $body.removeClass('modal-active'); },
onPopupOpen: function() { $body.addClass('modal-active'); },
overlayOpacity: 0,
popupCloserText: '',
popupHeight: 150,
popupLoaderText: '',
popupSpeed: 300,
popupWidth: 150,
selector: '.thumb > a.image',
usePopupCaption: true,
usePopupCloser: true,
usePopupDefaultStyling: false,
usePopupForceClose: true,
usePopupLoader: true,
usePopupNav: true,
windowMargin: 50
});
// Hack: Set margins to 0 when 'xsmall' activates.
breakpoints.on('<=xsmall', function() {
$main[0]._poptrox.windowMargin = 0;
});
breakpoints.on('>xsmall', function() {
$main[0]._poptrox.windowMargin = 50;
});
})(jQuery);
I have searched every stackoverflow method mentioning a thumbnail and video, I am honestly stuck. I have been playing around with the tags and attributes but I have seem to be getting no where.
Try setting up your <article> as:
<article class="thumb">
<a href="images/fulls/16.mp4">
<img src="images/thumbs/ab22.jpg" class="image" alt="" />
</a> <h2> Getting to the work</h2>
<p>Photoshoot with Myself </p>
</article>
Related
Ok, I'll try to explain as best I can.
Here is my code:
HTML:
<div class="mobile-wrapper">
<div id="mobile" class="mobile">
<img src="assets/images/mobile-moments-away-img.png">
<img id="mobile-close-btn" class="mobile-close-btn" src="assets/images/mobile-close-button-img.png" onclick="handleClose(this)">
<img id="mobile-continue-btn" class="mobile-continue-btn" src="assets/images/mobile-continue-now-img.png">
</div>
</div>
JS:
const handleClose = (elem) => {
console.log(elem);
elem.style.display = "none";
};
So, currently the handclose function currently hides the element, in this case it closes the image that has onclick="handleClose(this). What I need, is that when I click that image, it closes the mobile class instead of closing that image. So I am unsure how to reference the mobile class whilst still using this.
I have to use this as I have been asked too. Because I have the same HTML as above but for different images, as the JavaScript functions will doing the same thing for the above HTML as well as the different images I have. For example: My handleclose function will be using different elements but doing the same thing, hence why I am using this. So I would appreciate some help with this, and not to be told to do it a different way ie getelementbyid as that's not what I need.
Also, how would I be able to use elem.parentElement in this function, where popUp should be elem.parentElement
document.addEventListener("visibilitychange", () => {
if (!cookieExists()) {
popUp.style.visibility = "visible";
// popUp.style.top = "10vh";
document.cookie = `${cookieName}=true;max-age=604800;SameSite=None; Secure`;
}
});
You can refer to the parent element using .parentElement:
const handleClose = (elem) => {
elem.parentElement.style.display = "none";
};
<div class="mobile-wrapper">
<div id="mobile" class="mobile">
<img src="assets/images/mobile-moments-away-img.png">
<img id="mobile-close-btn" class="mobile-close-btn" src="assets/images/mobile-close-button-img.png" onclick="handleClose(this)">
<img id="mobile-continue-btn" class="mobile-continue-btn" src="assets/images/mobile-continue-now-img.png">
</div>
<div id="mobile" class="mobile">
<img src="assets/images/mobile-moments-away-img.png">
<img id="mobile-close-btn" class="mobile-close-btn" src="assets/images/mobile-close-button-img.png" onclick="handleClose(this)">
<img id="mobile-continue-btn" class="mobile-continue-btn" src="assets/images/mobile-continue-now-img.png">
</div>
<div id="mobile" class="mobile">
<img src="assets/images/mobile-moments-away-img.png">
<img id="mobile-close-btn" class="mobile-close-btn" src="assets/images/mobile-close-button-img.png" onclick="handleClose(this)">
<img id="mobile-continue-btn" class="mobile-continue-btn" src="assets/images/mobile-continue-now-img.png">
</div>
</div>
I am developing a product sale page. I have used a jquery plugin for implementing a carousel image.
Thats the library:
https://www.jqueryscript.net/demo/Carousel-Plugin-jQuery-RV-Gallery/
I am using the image statically for testing, with some images from internet. But I have to store the images dynamically, so amb I trying to iterate an ARRAY inside html. That array is html formatted.
I need to replace the shopify links, for the content of the arrayImagesProduct. Each product, it may have one, two, three,.. images. So I need to iterate the array .
I have tried this:
$("#productImages").html(arrayImagesProduct.join(''));
but then the slider it doesnt work. I get this error:
Uncaught TypeError: Cannot read property 'clientWidth' of undefined
at Gallery.countMoveRight (RV-gallery.js:121)
at RV-gallery.js:36
at dispatch (VM1025 jquery-1.12.4.js:5226)
at elemData.handle (VM1025 jquery-1.12.4.js:4878)
function showProduct(productCode){
var arrayImagesProduct = [];
$.post('../ServletJson', {
elem : 'productInfo',
code: productCode,
}, function(data) {
$.each(data,function(t,elem){
/* some stuff */
arrayImagesProduct.push('<img class="gallery-item" src="../loadImgProduct.jsp?idImg='+elem.idImg+'&code=productCode">');
});
$("#productImages").html(arrayImagesProduct.join(''));
});
}
How I can iterate the arrayImagesProduct array inside the html?
Inside here
<div class="gallery" id="productImages">
<!-- iterate arrayImagesProduct -->
<\div>
<body>
<div class="container-fluid">
<div class="row image-gallery-container">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 ">
<div class="gallery" id="productImages">
<img class="gallery-item" src="https://cdn.shopify.com/s/files/1/0122/2724/8185/products/0719_2019_Top1_b_ae870642-af0d-4655-811d-d597ed2a8bcc_720x.jpg?v=1574239406">
<img class="gallery-item" src="https://cdn.shopify.com/s/files/1/0122/2724/8185/products/0719_2019_Top1_a_720x.jpg?v=1574239409">
</div>
</div>
</div>
<!-- more content -->
</div>
</body>
Uncaught TypeError: Cannot read property 'clientWidth' of undefined
at Gallery.countMoveRight (RV-gallery.js:121)
at RV-gallery.js:36
at dispatch (VM1025 jquery-1.12.4.js:5226)
at elemData.handle (VM1025 jquery-1.12.4.js:4878)
The carousel is instantiating doing the declaration:
<div class="gallery">
jQuery('.gallery').eq(0).initGallery({
nav: ['<i class="material-icons">keyboard_arrow_left</i>', '<i class="material-icons">keyboard_arrow_right</i>'],
close: "<i class='material-icons'>close</i>",
aspectRatio: 3/2,
showDots: true,
showNavIfOneItem: false,
showNav: false,
arrows: true,
transition: "slide",
transitionTime: 700,
});
jQuery.fn.initGallery = function(options) {
if(!options) {
options={};
}
var galleries=[];
for (let i=0; i<this.length; i++) {
options.gallery = this.eq(i);
galleries[i] = new Gallery(options);
}
};
I'm using wordpress to set up a website. When putting in a specific block of code wordpress for seemingly no reason will add additional HTML into my code that screws up the formatting. I've looked it over and found no noticeable errors that would cause that behavior. This is the relevant bit of code (I've included most of it as I don't know where the issue actually lies)
<div class = "section">
<script type="text/javascript">
var imageCount = 0;
var position = 0;
var isStopped = false;
$( document ).ready(function() {
imageCount = document.getElementsByClassName("rotator").length; //Pull all elements into an array and count the number to get the count.
//setButtons();
});
function nextImage() {
var rotationNumber = $('#imgGal').width() * imageCount; //determines when it should cycle back to the beginning
position += $('#imgGal').width();//position change to width of the element
if (position >= rotationNumber) //cycle once the end is reached
{
position = 0;
}
//jquery to animate the transition
$( ".rotator" ).animate({
right: position
}, 1000 );
}
function previousImage() {
var rotationNumber = $('#imgGal').width() * imageCount; //determines the end
if (position <= 0) //cycle once the beginning is reached
{
position = rotationNumber - $('#imgGal').width();
}
else{
position -= $('#imgGal').width();//position change to width of the element
}
//jquery to animate the transition
$( ".rotator" ).animate({
right: position
}, 1000 );
}
</script>
<div id = "testimonials">
<a class = "controls" onclick="previousImage()"><div class = "arrow"><</div></a><!--
--><div id = "imgGal">
<div class = "rotator">
<div class = "blurb">
<h3>John Doe</h3><p>"Positive Testimonial"</p>
</div>
</div><!--
--><div class = "rotator">
<div class = "blurb">
<h3>John Doe the Second</h3><p>"Positive Testimonial"</p>
</div>
</div>
</div><!--
--><a class = "controls" onclick="nextImage()"><div class = "arrow">></div></a>
</div>
</div>
</div>
And this is what it looks like after being published
<div class="section">
<script type="text/javascript">
var imageCount = 0;
var position = 0;
var isStopped = false;
$( document ).ready(function() {
imageCount = document.getElementsByClassName("rotator").length; //Pull all elements into an array and count the number to get the count.
//setButtons();
});</p>
<p> function nextImage() {
var rotationNumber = $('#imgGal').width() * imageCount; //determines when it should cycle back to the beginning
position += $('#imgGal').width();//position change to width of the element
if (position >= rotationNumber) //cycle once the end is reached
{
position = 0;
}</p>
<p> //jquery to animate the transition
$( ".rotator" ).animate({
right: position
}, 1000 );
}
function previousImage() {
var rotationNumber = $('#imgGal').width() * imageCount; //determines the end</p>
<p> if (position <= 0) //cycle once the beginning is reached
{
position = rotationNumber - $('#imgGal').width();
}
else{
position -= $('#imgGal').width();//position change to width of the element
}
//jquery to animate the transition
$( ".rotator" ).animate({
right: position
}, 1000 );
}
</script><p></p>
<div id="testimonials">
<a class="controls" onclick="previousImage()"><p></p>
<div class="arrow"><</div>
</a><p><a class="controls" onclick="previousImage()"></a><!--
--></p>
<div id="imgGal">
<div class="rotator">
<div class="blurb">
<h3>John Doe</h3>
<p>"Positive Testimonial"</p>
</div>
</div>
<p><!--
--></p>
<div class="rotator">
<div class="blurb">
<h3>John Doe the Second</h3>
<p>"Positive Testimonial"</p>
</div>
</div>
</div>
<p><!--
--><a class="controls" onclick="nextImage()"></a></p><a class="controls" onclick="nextImage()">
<div class="arrow">></div>
</a><p><a class="controls" onclick="nextImage()"></a>
</p></div>
</div>
Notice the doubling of elements and insertion of random p tags? I haven't been able to find anything on this so I'm kind of stumped. If I isolate the code it's happening on and just throw it in a non-wordpress HTML page by itself the issue doesn't happen. It's happening specifically on the a tags that I'm using to trigger the javascript
The code that is actually having the issue
Goes from this
<a class = "controls" onclick="previousImage()"><div class = "arrow"><</div></a>
<a class = "controls" onclick="nextImage()"><div class = "arrow">></div></a>
to this
<a class="controls" onclick="previousImage()"><p></p>
<div class="arrow"><</div>
</a><p><a class="controls" onclick="previousImage()"></a><!--
--></p>
<a class="controls" onclick="nextImage()"></a></p><a class="controls" onclick="nextImage()">
<div class="arrow">></div>
</a><p><a class="controls" onclick="nextImage()"></a>
As #janh2 has stated. This is most likely down to 'wpautop' - https://codex.wordpress.org/Function_Reference/wpautop
You can disable it by adding the following code:
remove_filter( 'the_content', 'wpautop' );
or
remove_filter( 'the_excerpt', 'wpautop' );
or both...
I have to ask though, why are you adding JavaScript in to a WordPress page content? It's not the recommended way to add JavaScript code to a WordPress site and it should be enqueued as per the documentation in the WordPress Codex:
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
This problem has been driving me up the wall for months. I can't figure out why my background on my website:
www.the-ruck.us
Doesn't load properly.
I know the code works, because when I run it on my computer, everything loads fine. However, when I publish it to the web, and browse to my page, the slideshow just stays blank.
Here's the API for the XMLLoader class I use
Here's the code:
var slideshowXMLLoader:XMLLoader = new XMLLoader("slideshow.xml", {autoDispose:true, onComplete:LoadXML});
slideshowXMLLoader.load();
function LoadXML(e:Event) {
slideshowXML = new XML(e.target.content);
parse(slideshowXML);
}
function parse(ssXML:XML) { wallpaperLinks = slideshowXML.img.attributes(); }
function loadFirstPaper() {
ticker.addEventListener(TimerEvent.TIMER, changePaper);
TweenMax.to(landing, .5, {alpha:0, ease:Quint.easeOut});
TweenMax.to(bloomer, 1, {alpha:0, ease:Quint.easeOut});
loadWallpaper(randomNumber());
}
function loadWallpaper(i:Number) {
paperCounter = i;
var loader:Loader = new Loader();
var req:URLRequest = new URLRequest(wallpaperLinks[paperCounter]);
loader.load(req);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeIn);
}
function fadeIn(e:Event) {
if (!isPaused) ticker.start();
var temp = e.target.content;
wallpaper.addChild(temp);
TweenMax.from(temp, fadeTime, {alpha:0, ease:Quint.easeOut});
}
function changePaper(e:Event) {
ticker.stop();
loadWallpaper(randomNumber());
}
function randomNumber():Number
{ return Math.floor(Math.random() * 53); }
}
slideshow.xml contains this:
<wallpapers>
<img link="imgs/one.jpg"></img>
<img link="imgs/two.jpg"></img>
<img link="imgs/three.jpg"></img>
<img link="imgs/four.jpg"></img>
<img link="imgs/five.jpg"></img>
<img link="imgs/six.jpg"></img>
<img link="imgs/seven.jpg"></img>
<img link="imgs/eight.jpg"></img>
<img link="imgs/nine.jpg"></img>
<img link="imgs/ten.jpg"></img>
<img link="imgs/eleven.jpg"></img>
<img link="imgs/twelve.jpg"></img>
<img link="imgs/thirteen.jpg"></img>
<img link="imgs/fourteen.jpg"></img>
<img link="imgs/fifteen.jpg"></img>
<img link="imgs/sixteen.jpg"></img>
<img link="imgs/seventeen.jpg"></img>
<img link="imgs/eighteen.jpg"></img>
<img link="imgs/nineteen.jpg"></img>
<img link="imgs/twenty.jpg"></img>
<img link="imgs/twentyone.jpg"></img>
<img link="imgs/twentytwo.jpg"></img>
<img link="imgs/twentythree.jpg"></img>
<img link="imgs/twentyfour.jpg"></img>
<img link="imgs/twentyfive.jpg"></img>
<img link="imgs/twentysix.jpg"></img>
<img link="imgs/twentyseven.jpg"></img>
<img link="imgs/twentyeight.jpg"></img>
<img link="imgs/twentynine.jpg"></img>
<img link="imgs/thirty.jpg"></img>
<img link="imgs/thirtyone.jpg"></img>
<img link="imgs/thirtytwo.jpg"></img>
<img link="imgs/thirtythree.jpg"></img>
<img link="imgs/thirtyfour.jpg"></img>
<img link="imgs/thirtyfive.jpg"></img>
<img link="imgs/thirtysix.jpg"></img>
<img link="imgs/thirtyseven.jpg"></img>
<img link="imgs/thirtyeight.jpg"></img>
<img link="imgs/thirtynine.jpg"></img>
<img link="imgs/fourty.jpg"></img>
<img link="imgs/fourtyone.jpg"></img>
<img link="imgs/fourtytwo.jpg"></img>
<img link="imgs/fourtythree.jpg"></img>
<img link="imgs/fourtyfour.jpg"></img>
<img link="imgs/fourtyfive.jpg"></img>
<img link="imgs/fourtysix.jpg"></img>
<img link="imgs/fourtyseven.jpg"></img>
<img link="imgs/fourtyeight.jpg"></img>
<img link="imgs/fourtynine.jpg"></img>
<img link="imgs/fifty.jpg"></img>
<img link="imgs/fiftyone.jpg"></img>
<img link="imgs/fiftytwo.jpg"></img>
<img link="imgs/fiftythree.jpg"></img>
</wallpapers>
I've tried running Firebug on my site, and, unless I was doing that wrong, too, no errors or warnings came up. So I'm completely stumped. Anybody have any ideas?
Any help is deeply appreciated, thank you.
OK here is what I believe is happening. I went to your site and it throws a null reference error in loadWallpaper(). This only thing in loadWallpaper() that could be null that I can tell is wallpaperLinks. wallpaperLinks is set after the XMLLoader has completed it's load. You didn't show the code that calls loadFirstPaper(). So I bet you have a race condition. On your computer, the local load of the XML happens faster than online so you don't see it local.
Do this, move you loadFirstPaper call to here:
function parse(ssXML:XML) {
wallpaperLinks = slideshowXML.img.attributes();
loadFirstPaper();
}
Figured it out. The problem was
var slideshowXMLLoader:XMLLoader = new XMLLoader("slideshow.xml", {autoDispose:true, onComplete:LoadXML});
Either the XMLLoader wasn't doing it's job at all; or, and I think this is more likely, the onComplete event was firing prematurely. I replaced the above line with:
var slideshowXMLLoader:URLLoader = new URLLoader();
slideshowXMLLoader.addEventListener(Event.COMPLETE, loadXML);
slideshowXMLLoader.load(new URLRequest("slideshow.xml"));
It currently appears to be working as intended.
I would still like to know how to make onComplete calls work properly, so if anybody has any advice, I would love to hear it.
Thanks.
Regarding the audio on this page: http://ebonytay.com/site/composer.php?clip=getOutOfTown#mediaplayer
The audio controls show up in Chrome and Safari (and in Firefox locally. I'm having problems with a specific live server working but that's irrelevant). In IE9 however, the audio control is invisible. The music is still playing and if you right click on where it's suppose to be, you can play/pause it, it just doesn't show up.
I've tried messing with the z-index. I've tried putting it outside all the divs. I've tried using src= instead of source. I've tried using controls instead of controls="controls". I've tried using the audio tag directly sourcing the file, without any PHP/Javascripting. I'm fairly new to programming so I'm sure some of the code could be written simpler, but it shouldn't be breaking anything. Any help would be appreciated.
Here is all the code for the audio player (not incl. css) on the page:
<?php
$song = "overtureRedRockRise"; // set to starting song
$autoplay = ""; // disable autoplay on page load
$totalSlides = 1; //default amount of slides
$initialSlide = 1; //default starting slide
// Change song to URL parameter defined by links in #clip_nav div
if (isset($_GET["clip"])) // if URL parameter is ?clip=foo
{
$song = $_GET["clip"]; // $song is foo
$autoplay = "autoplay='autoplay'"; // enable autoplay when changing song
}
// Check how many slideshow images exist for current song
while (file_exists("../audio/filmClip_" . $song . "_" . $totalSlides . ".jpg"))
{
$totalSlides++;
}
$totalSlides--; // subtract 1 to get total number of slides for current song
?>
<script>
$(document).ready(function() {
var currentSlide = 1; //default starting slide
var totalSlides; //number of slides for current song
var song; //current song
var slideSpeed; //current slideshow speed
// Get variables from PHP
totalSlides = <?php echo $totalSlides ?>;
song = "<?php echo $song ?>";
// Setup slideshow speeds in milliseconds using JSON
var songSpeed =
[
['overtureRedRockRise',12000],
['getOutOfTown',7000],
['canyonBaby', 5000],
['celestialGuides', 10000],
['springback', 11000],
['hallelujas', 10000],
['myOnly', 8000],
['selfDefense', 10000],
['orchestral', 10000]
]
//go through each song in array
for (i = 0; i < 9; i++)
{
//find the current song
if (song == songSpeed[i][0])
{
//set current slideshow speed
slideSpeed = songSpeed[i][1] + 1000; //add 1 second for loading time
}
}
// Setup slideshow
function changeSlide()
{
// change current slide number
currentSlide++;
// Loop slideshow
if (currentSlide > totalSlides) { currentSlide = 1; }
// Display current slide
$('.song_image').attr('src', '../audio/filmClip_' + song + '_' + currentSlide + '.jpg');
}
// If song has more than 1 image
if (totalSlides > 1)
{
// Play slideshow
setInterval(changeSlide, slideSpeed);
}
// Indicate current song
$('div.filmClip_list.'+song).addClass('currentSong');
});
</script>
<h2><a id="mediaplayer"> SCORE AUDIO LIBRARY</a></h2>
<div id="audio_clips">
<!-- Song List -->
<div id="clip_nav">
<div class="filmClip_list overtureRedRockRise">Overture - Red Rock Rise</div>
<div class="filmClip_list getOutOfTown">Get Out of Town Firehorse</div>
<div class="filmClip_list canyonBaby">Lady Sedona Vortex</div>
<div class="filmClip_list celestialGuides">Celestial Guides</div>
<div class="filmClip_list springback">Springbank Park / Lawson Road</div>
<div class="filmClip_list hallelujas">Hallelujahs</div>
<div class="filmClip_list myOnly">My Only</div>
<div class="filmClip_list selfDefense">Self Defense</div>
<div class="filmClip_list orchestral">The Return of the Chevalier <i>(orchestral)</i></div>
</div><!-- end #clip_nav-->
<!-- Slideshow -->
<div id="image_holder">
<img class="song_image" src="../audio/filmClip_<?php echo $song ?>_<?php echo $initialSlide ?>.jpg" width="600" height="400" alt="Slideshow" />
</div><!-- end #image_holder-->
<!-- Audio -->
<div id="audio_player">
<audio controls="controls" preload="auto" <?php echo $autoplay ?>>
<source src="../audio/filmClip_<?php echo $song ?>.ogg" type="audio/ogg" />
<source src="../audio/filmClip_<?php echo $song ?>.mp3" type="audio/mpeg" />
Your browser does not support audio. Please upgrade your internet browser to the latest version here.
</audio>
</div><!-- end #audio_player -->
</div><!-- end #audio_clips -->
It's this rule in style_2011.css:
body.composer audio {
height: 32px;
width: 100%;
}
Specifically, if you set height to 45px or more then the controls will appear.
Just remove the height of the audio tag.