Wordpressで実装したいHPで画像をタップ(クリック)したら他のページやサイトに飛べるようにしたいのですが、The image #~ couldn't be loadedと表示され何度違うやり方でやってもできませんでした。
通常のhtml&cssのやり方だとできると思うのですが、javascriptを画像のエフェクトとして入れているのでやり方が変わるのだと思いますが、やり方がわからず詰まっています。
もし、わかる方いましたら教えいただきますと助かります。お願いします!!
###index.php
html
1<!-- Portfolio--> 2 <section class="page-section bg-dark" id="portfolio"> 3 4 <!-- Call to action--> 5 <div class="container"> 6 <div class="row justify-content-center"> 7 <div class="col-lg-8 text-center"> 8 <h2 class="text-white mt-0">ああああ</h2> 9 <hr class="divider my-4" /> 10 <p class="text-white-50 mb-4">ああああ(</p> 11 </div> 12 </div> 13 <div class="row justify-content-center"> 14 <div class="col-lg-4 col-sm-6"> 15 <!-- hover effect 1(start) --> 16 <figure class="snip1200"> 17 <img src="<?php echo get_template_directory_uri(); ?>/assets/img2/sq-sample27.jpg" alt="sq-sample27" /> 18 <figcaption> 19 <p>I say, if your knees aren't green by the end of the day, you ought to seriously re-examine your life.</p> 20 <div class="heading"> 21 <h2><span>Cafe</span></h2> 22 </div> 23 </figcaption> 24 <a href="#"></a> 25 </figure> 26 <!-- hover effect 1(end)--> 27 </div>
###header.php
php
1<?php 2function twpp_enqueue_scripts() { 3 wp_enqueue_script( 4 'scripts-script', 5 get_template_directory_uri() . '/js/scripts.js', 6 ); 7 wp_enqueue_script( 8 'common-script', 9 get_template_directory_uri() . '/js/common.js', 10 array( 'scripts-script' ) 11 false, 12 true 13 ); 14} 15add_action( 'wp_enqueue_scripts', 'twpp_enqueue_scripts' ); 16?> 17
###styles.css
css
1@import url(https://fonts.googleapis.com/css?family=Raleway:400,500,800); 2figure.snip1200 { 3font-family: 'Raleway', Arial, sans-serif; 4position: relative; 5overflow: hidden; 6margin: 10px; 7min-width: 220px; 8max-width: 310px; 9max-height: 310px; 10width: 100%; 11background: #000000; 12color: #ffffff; 13text-align: center; 14box-shadow: 0 0 5px rgba(0, 0, 0, 0.15); 15font-size: 16px; 16} 17figure.snip1200 * { 18-webkit-box-sizing: border-box; 19box-sizing: border-box; 20-webkit-transition: all 0.45s ease-in-out; 21transition: all 0.45s ease-in-out; 22} 23figure.snip1200 img { 24max-width: 100%; 25position: relative; 26opacity: 0.9; 27} 28figure.snip1200 figcaption { 29position: absolute; 30top: 45%; 31left: 7%; 32right: 7%; 33bottom: 45%; 34border: 1px solid white; 35border-width: 1px 1px 0; 36} 37figure.snip1200 .heading { 38overflow: hidden; 39-webkit-transform: translateY(50%); 40transform: translateY(50%); 41position: absolute; 42bottom: 0; 43width: 100%; 44} 45figure.snip1200 h2 { 46display: table; 47margin: 0 auto; 48padding: 0 10px; 49position: relative; 50text-align: center; 51width: auto; 52text-transform: uppercase; 53font-weight: 400; 54} 55figure.snip1200 h2 span { 56font-weight: 800; 57} 58figure.snip1200 h2:before, 59figure.snip1200 h2:after { 60position: absolute; 61display: block; 62width: 1000%; 63height: 1px; 64content: ''; 65background: white; 66top: 50%; 67} 68figure.snip1200 h2:before { 69left: -1000%; 70} 71figure.snip1200 h2:after { 72right: -1000%; 73} 74figure.snip1200 p { 75top: 50%; 76-webkit-transform: translateY(-50%); 77transform: translateY(-50%); 78position: absolute; 79width: 100%; 80padding: 0 20px; 81margin: 0; 82opacity: 0; 83line-height: 1.6em; 84font-size: 0.9em; 85} 86figure.snip1200 a { 87left: 0; 88right: 0; 89top: 0; 90bottom: 0; 91position: absolute; 92z-index: 1; 93} 94figure.snip1200:hover img, 95figure.snip1200.hover img { 96opacity: 0.25; 97-webkit-transform: scale(1.1); 98transform: scale(1.1); 99} 100figure.snip1200:hover figcaption, 101figure.snip1200.hover figcaption { 102top: 7%; 103bottom: 7%; 104} 105figure.snip1200:hover p, 106figure.snip1200.hover p { 107opacity: 1; 108-webkit-transition-delay: 0.35s; 109transition-delay: 0.35s; 110}
###scripts.js -new-
javascript
1(function($) { 2 "use strict"; // Start of use strict 3 4 // Smooth scrolling using jQuery easing 5 $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() { 6 if (location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '') && location.hostname == this.hostname) { 7 var target = $(this.hash); 8 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 9 if (target.length) { 10 $('html, body').animate({ 11 scrollTop: (target.offset().top - 72) 12 }, 1000, "easeInOutExpo"); 13 return false; 14 } 15 } 16 }); 17 18 // Closes responsive menu when a scroll trigger link is clicked 19 $('.js-scroll-trigger').click(function() { 20 $('.navbar-collapse').collapse('hide'); 21 }); 22 23 // Activate scrollspy to add active class to navbar items on scroll 24 $('body').scrollspy({ 25 target: '#mainNav', 26 offset: 75 27 }); 28 29 // Collapse Navbar 30 var navbarCollapse = function() { 31 if ($("#mainNav").offset().top > 100) { 32 $("#mainNav").addClass("navbar-scrolled"); 33 } else { 34 $("#mainNav").removeClass("navbar-scrolled"); 35 } 36 }; 37 // Collapse now if page is not at top 38 navbarCollapse(); 39 // Collapse the navbar when page is scrolled 40 $(window).scroll(navbarCollapse); 41 42 // Magnific popup calls 43 $('#portfolio').magnificPopup({ 44 delegate: 'a', 45 type: 'image', 46 tLoading: 'Loading image #%curr%...', 47 mainClass: 'mfp-img-mobile', 48 gallery: { 49 enabled: true, 50 navigateByImgClick: true, 51 preload: [0, 1] 52 }, 53 image: { 54 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.' 55 } 56 }); 57})(jQuery); // End of use strict 58$(".hover").mouseleave( 59function () { 60 $(this).removeClass("hover"); 61} 62); 63$('#test').on('click', function(e){ 64e.stopPropagation(); 65})
###scripts.js -old-
javascript
1 (function($) { 2 "use strict"; // Start of use strict 3 4 // Smooth scrolling using jQuery easing 5 $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() { 6 if (location.pathname.replace(/^//, '') == this.pathname.replace(/^//, '') && location.hostname == this.hostname) { 7 var target = $(this.hash); 8 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 9 if (target.length) { 10 $('html, body').animate({ 11 scrollTop: (target.offset().top - 72) 12 }, 1000, "easeInOutExpo"); 13 return false; 14 } 15 } 16 }); 17 18 // Closes responsive menu when a scroll trigger link is clicked 19 $('.js-scroll-trigger').click(function() { 20 $('.navbar-collapse').collapse('hide'); 21 }); 22 23 // Activate scrollspy to add active class to navbar items on scroll 24 $('body').scrollspy({ 25 target: '#mainNav', 26 offset: 75 27 }); 28 29 // Collapse Navbar 30 var navbarCollapse = function() { 31 if ($("#mainNav").offset().top > 100) { 32 $("#mainNav").addClass("navbar-scrolled"); 33 } else { 34 $("#mainNav").removeClass("navbar-scrolled"); 35 } 36 }; 37 // Collapse now if page is not at top 38 navbarCollapse(); 39 // Collapse the navbar when page is scrolled 40 $(window).scroll(navbarCollapse); 41 42 // Magnific popup calls 43 $('#portfolio').magnificPopup({ 44 delegate: 'a', 45 type: 'image', 46 tLoading: 'Loading image #%curr%...', 47 mainClass: 'mfp-img-mobile', 48 gallery: { 49 enabled: true, 50 navigateByImgClick: true, 51 preload: [0, 1] 52 }, 53 image: { 54 tError: '<a href="%url%">The image #%curr%</a> could not be loaded.' 55 } 56 }); 57 58})(jQuery); // End of use strict 59
###common.js
javascript
1 $(".hover").mouseleave( 2 function () { 3 $(this).removeClass("hover"); 4 } 5 );
回答1件
あなたの回答
tips
プレビュー