Search code examples
laravelfancyboxlightbox

Lightbox doesn't work in laravel app


I am trying to implement lightbox in laravel but it doesn't load the arrows(left,right ...) from the lightbox css file.With Fancybox i have an issue when i click on the image, the size overflows for 1,2s and then it appears at the normal size in the center of the screen(I have image below).The arrows path public/lightbox/img.

Below is my code

default.blade.php

   <title>My personal website</title>
   <link rel="shortcut icon" href="{{ asset('favicon.png') }}" >
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
   <link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"/>
   <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
   <link rel="stylesheet" href="{{ asset('css/style.css') }}" type="text/css"/>
   <link rel="stylesheet" href="{{ asset('css/lightbox.css') }}" type="text/css"/>

 </head>
 <body>

   <div class="container">
     <header>
       @include('template.partial.nav')
     </header>
      @yield('content')
   </div>

   @include('template.partial.footer')

   <!-- ***Scripts*** -->
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

   <!-- Add fancyBox -->
   <script type="text/javascript" src="js/lightbox.min.js"></script>

   <!-- Latest compiled and minified JavaScript -->
   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

   <script type="text/javascript" src="{{ asset('js/test.js') }}"></script>

 </body>
</html>

portfolio.blade.php

@extends('template.default')

@section('content')
<div id="portfolio">
     <div class="row">
       <p class="heading">Portfolio</p>
     </div>
     <div class="row">
       <div class="col-md-12">
         <p class="subheading">Java application</p>
         <hr>
         <h2 style="text-align:center">Lightbox</h2>
         <a data-lightbox="roadtrip" href="{{ asset('lightbox/img/demopage/rsz_java1.png') }}">
            <img src="{{ asset('lightbox/img/demopage/java1.png') }}" width="150" height="100">
         </a>
         <a data-lightbox="roadtrip" href="{{ asset('lightbox/img/demopage/rsz_java1.png') }}">
            <img src="{{ asset('lightbox/img/demopage/java1.png') }}" width="150" height="100">
         </a>
       </div>
      </div>

@endsection

Console errors:

portfolio:1 GET http://{projectname}/img/next.png 404 (Not Found)
portfolio:1 GET http://{projectname}/img/close.png 404 (Not Found)
portfolio:1 GET http://{projectname}/img/loading.gif 404 (Not Found)
portfolio:1 GET http://{projectname}/img/prev.png 404 (Not Found)

Thanks in advance! enter image description here


Solution

  • Please, upgrade jQuery to the latest (see https://github.com/fancyapps/fancybox/issues/1504)

    Also, fancyBox v3 does not use any images, all icons (including loading animation) are created using CSS only. Make sure you are not mixing multiple lightbox scripts.