Here we will learn how to install and utilize Galleria plugins. There are several different plugins that will allow you to enhance Galleria in many different ways.
Using the myfirstgallery.html
file we created in the first section, we'll customize it to include the history plugin that is packaged with Galleria.
All that is required to install a plugin is to include its JavaScript file. Place the following code inside the head
tag:
<script src="../galleria-1.2.8.min.js"></script>
<script src="../plugins/history/galleria.history.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
Galleria.loadTheme('../themes/classic/galleria.classic.min.js');
Galleria.run('#galleria');
});
</script>
With plugins, it's possible to hook into Galleria to customize its behavior. This ranges from customizing how Galleria retrieves its images, what images it loads, and how it handles JavaScript events.
In the case of the history plugin for image change, it adds a hash value to the URL so that each image visited in the gallery can have a unique URL. This allows users to link directly to an image inside the gallery. Then, when the page is requested with the specified hash, it will load that image instead of the initial image in the gallery and also allow the user to go backward/forward in history.