I’m certainly doing something wrong, but here is my code. I’ve made a template_part for this theme, so all of the slider-related stuff is in there. The slider itself functions as anticipated.
<?php $featured_thumb_id = get_post_meta($post->ID, '_thumbnail_id', true);
$featured_thumb_data = get_post_meta($featured_thumb_id,'_wp_attachment_metadata', true);
$featured_thumb_url = wp_get_original_image_url( $featured_thumb_id );
$featured_thumb_height = $featured_thumb_data["height"];
$featured_thumb_width = $featured_thumb_data["width"];
$featured_thumb_alt = $featured_thumb_data["foo"];
$featured_thumb_caption = wp_get_attachment_caption($featured_thumb_id);
var_dump();
$gallery_images = get_field('post_gallery');
?>
<?php
wp_enqueue_style('royalslider-styles', get_stylesheet_directory_uri() . '/assets/plugins/royalslider/royalslider.css');
wp_enqueue_style('royalslider-skin', get_stylesheet_directory_uri() . '/assets/plugins/royalslider/rs-default.css');
wp_enqueue_script('royalslider-script', get_stylesheet_directory_uri() . '/assets/plugins/royalslider/jquery.royalslider.min.js', array('jquery'), '1.0.6', false);
wp_enqueue_script( 'rs-thumbs-init2', get_stylesheet_directory_uri() . '/parts/gallery/init/post-default-thumbs-init.js', array('jquery'), '1.0.6', true );
?>
<?php if ($gallery_images) {
echo "I have a gallery";} ?>
<style>
#post-default-slider {width:100%}
#post-default-slider {height:400px}
</style>
<div id="post-default-slider" class="royalSlider rsDefault">
<?php echo "<a class=\"rsImg\" data-rsw=\"$featured_thumb_width\" data-rsh=\"$featured_thumb_height\" data-rsBigImg=\"$featured_thumb_url\" href=\"$featured_thumb_url\"> <img width=\"96\" height=\"72\" class=\"rsTmb\" src=\"$featured_thumb_url\" />
<div class=\"overlay\"> <h4>I am overlay</h4> </div>
</a>"; ?>
</div>
<script>
jQuery(document).ready(function($) {
$('#post-default-slider').royalSlider({
fullscreen: {
enabled: true,
nativeFS: true
},
controlNavigation: <?php if ($gallery_images){echo "'thumbnails'";} else {echo "'none'";}?>,
autoScaleSlider: true,
autoScaleSliderWidth: 600,
autoScaleSliderHeight: 480,
loop: false,
imageScaleMode: 'fit-if-smaller',
navigateByClick: true,
numImagesToPreload:2,
arrowsNav:true,
arrowsNavAutoHide: true,
arrowsNavHideOnTouch: true,
keyboardNavEnabled: true,
fadeinLoadedSlide: true,
globalCaption: true,
globalCaptionInside: false,
thumbs: {
appendSpan: true,
firstMargin: true,
paddingBottom: 4
}
});
$('.rsContainer').on('touchmove touchend', function(){});
});
$('#go-full-screen').click(function() {
slider.enterFullScreen();
slider.goTo(1);
});
</script>
<button type="button" id="go-full-screen">
<?php echo"<img src=\"$featured_thumb_url\">"; ?>
</button>
JQMIGRATE: Migrate is installed, version 3.3.2
VM480:6327 Uncaught TypeError: $ is not a function
at VM480:6327
(anonymous) @ VM480:6327
VM481:6340 Uncaught SyntaxError: Unexpected token ')'
goMap.min.js?ver=2.1.0.13:1 Leaflet | OpenStreetMap API Loaded :)
goMap.min.js?ver=2.1.0.13:1 osm
goMap.min.js?ver=2.1.0.13:1 osm
post-default-thumbs-init.js?ver=1.0.6:1 Uncaught SyntaxError: Unexpected token '<'
5[Violation] Added non-passive event listener to a scroll-blocking <some> event. Consider marking event handler as 'passive' to make the page more responsive. See <URL>
comment-reply.min.js?ver=5.7.1:2 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
d @ comment-reply.min.js?ver=5.7.1:2
t @ comment-reply.min.js?ver=5.7.1:2
jquery.min.js?ver=3.5.1:2 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
add @ jquery.min.js?ver=3.5.1:2
s.event.add @ jquery-migrate.min.js?ver=3.3.2:2
(anonymous) @ jquery.min.js?ver=3.5.1:2
each @ jquery.min.js?ver=3.5.1:2
each @ jquery.min.js?ver=3.5.1:2
ke @ jquery.min.js?ver=3.5.1:2
on @ jquery.min.js?ver=3.5.1:2
(anonymous) @ (index):6322
e @ jquery.min.js?ver=3.5.1:2
t @ jquery.min.js?ver=3.5.1:2
comment-reply.min.js?ver=5.7.1:2 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
d @ comment-reply.min.js?ver=5.7.1:2
o @ comment-reply.min.js?ver=5.7.1:2
comment-reply.min.js?ver=5.7.1:2 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
d @ comment-reply.min.js?ver=5.7.1:2
o @ comment-reply.min.js?ver=5.7.1:2
comment-reply.min.js?ver=5.7.1:2 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
d @ comment-reply.min.js?ver=5.7.1:2
o @ comment-reply.min.js?ver=5.7.1:2
rs-default.css:1 GET http://dev.coosguide.com/dev2/wp-content/themes/Newspaper-child/assets/plugins/royalslider/rs-default.png 404 (Not Found)
rs-default.css:1 GET http://dev.coosguide.com/dev2/wp-content/themes/Newspaper-child/assets/plugins/preloaders/preloader-white.gif 404 (Not Found)
[Violation] Forced reflow while executing JavaScript took 55ms