Skip to content

Manual Installation

mamrey edited this page May 23, 2025 · 6 revisions

Based on your application needs, you may want to include only some of the views provided by this plugin. This can help limit the number of assets included in your application. If you don't care and want everything this plugin provides, follow the installation instructions in the README.

Instructions here are based on the 4.x and 5.x releases of this plugin, and would take the place of running the blacklight_gallery:install generator.

Gallery View

Using the gallery view does not require any additional javascript. Add the following configuration to your Blacklight config:

config.view.gallery(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::GalleryComponent)

Copy the _gallery.scss file from the gem into your app/assets/stylesheets directory, and import it in your stylesheet entrypoint file.

Masonry view

Using the masonry view requires adding jQuery and the masonry JS from the plugin. First, add the following configuration to the Blacklight config:

config.view.masonry(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::MasonryComponent)

Copy the _masonry.scss file from the gem into your app/assets/stylesheets directory, and import it in your stylesheet entrypoint.

If using Sprockets, append this to your manifest.js:

//= link blacklight_gallery/manifest.js

And this to your application.js (after require blacklight/blacklight):

//= require blacklight_gallery/blacklight-gallery

If using Importmaps, include jQuery as a pin in your importmap.rb:

pin "jquery", to: "https://code.jquery.com/jquery-3.7.1.min.js"

Import the required modules in your application.js:

import 'jquery'
import 'blacklight-gallery'

Slideshow View

You might as well use the blacklight_gallery:install generator.
Copy the _slideshow.scss file from the gem into your app/assets/stylesheets directory, and import it in your stylesheet entrypoint.

If you want to remove the other views, you can simply remove the lines that are added to your Blacklight configuration that are mentioned above for the other views.

Clone this wiki locally