Skip to content

Plugin doesn't work with Lightbox2 if --data parameter is empty or missing #8

@fkurz

Description

@fkurz

Issue

Leaving out the --data="..." parameter or leaving it empty is not supported by Lightbox2. Currently, there is no default value and image links produced by the lightbox plugin will not be picked up by Lightbox2.

See Initialize with HTML on the [https://lokeshdhakar.com/projects/lightbox2/](Lightbox2 documentation).

Expected behavior

There is a data-lightbox attribute on the image links produced by {% lightbox ... %} even if the --data parameter is empty or missing and the Lightbox2 modal will work.

Actual behavior

There is no or an empty data-lightbox attribute on the image links produced by {% lightbox ... %} if not provided explicitely via the --data parameter and the Lightbox2 modal won't work.

Suggested fix

The lightbox plugin should set default value for the data-lightbox attribute so that Lightbox2 will pick up on the image link.
E.g. in the render method, default the data-lightbox attribute value to @path (which should always be there).

     # Check if data is given and otherwise set to default
      data = @data.to_s.empty? ? @path : @data

      %{<a href="#{src}" data-lightbox="#{data}" data-title="#{@title}"><img src="#{thumbSrc}" alt="#{@alt || @title}" class="#{@class}" style="#{@img_style}"/></a>}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions