Featherlight and Image Caption plugins


#1

Hi all - I have both the Featherlight and the Image Caption plugins installed and running. Unfortunately the Image caption plugin seems to run after the Featherlight plugin, so figure tag gets surrounded by the a tag that Featherlight adds to run the lightbox effect.

I have tried limiting the scope of the Image Caption plugin to a[rel=“lightbox”], but that does not work. And adding the markdown for the image inside a figure tag does not work either.

Is there any way to delay the Featherlight plugin till after the caption plugin has done its work?


#3

I did try renaming the featherlight plugin folder to zz_featherweight, but it didn’t show up in the plugins list in admin pages. Realise now I should have cleared the cache. I’ll give that a go later on.


#4

In the plugin code itself, there is a “priority” integer that you can set. Higher numbers get executed before lower ones. (See comments in this example code from the docs.)

What seems to be missing is a way to alter plugin priorities outside of the code itself. I’m going to head over to the source code and see if this can be solved relatively easily or not.


#5

I’ll draft up an approach and a PR and we’ll see what the Grav team thinks of it. It’s certainly doable.


#6

Okay - seems I was wrong in my diagnosis. The a tag is not added by the featherlight plugin, but by the core markdown converter. So delaying the loading of the plugin makes no difference - the image is already within the a tag. Promoting the image-caption plugin would not work because there is no image tag for the plugin to find. To fix it - as far as I can see - the Image-caption plugin would need to check if the image tag is surrounded by an a tag, and copy the a tag as well as the image tag into the figure tag.

Should not be too hard (yeah right) and I will have a look later.

The way it is now works - but was showing up as invalid html in a validator. But the w3c validator says it is okay and the spec says it is okay, so I guess it can wait.

Cheers

Don


#7

I know this isn’t the solution to your problem, but I have submitted a PR to make it possible to override plugin handler priorities: https://github.com/getgrav/grav/pull/2165.


#8

The Plugin https://github.com/trilbymedia/grav-plugin-image-captions worked for me: Lightbox / Link + Image Caption.

Regards, Ralf