[SOLVED] Javascript in shortcodes


#1

Hi there, I’m trying to create a shortcode for galleria.js, but cannot get it running.

My shortcode is:

{{< flickr photoset_id="72157685132857311" >}}

in my layouts/shortcodes/flickr.html file, I’ve added:

<div class="galleria"></div>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/galleria/1.5.7/galleria.min.js"></script>

<script type="text/javascript">
  (function() {
      Galleria.loadTheme('https://cdnjs.cloudflare.com/ajax/libs/galleria/1.5.7/themes/classic/galleria.classic.min.js');
      Galleria.run('.galleria', {
        flickr: 'set:{{ .Get "photoset_id" }}',
        flickrOptions: {
          sort: 'date-posted-asc'
        }
      });
  });
    </script>

The problem, it doesn’t work. The HTML seems valids but it doesn’t show anything. I’ve tried with | safeJS (JavaScript on page) but still not working.

Thank you for your help! :smiley:


Galleria in a shortcode
#2

It was totally me!!

should have a height to be displayed.

\o/