App for Cloudflare® Pro

App for Cloudflare® Pro 1.9.9

  • Item seller Item seller Shawn
  • Featured

Incompatibility between using R2 for media and lightbox plugin

Simon

New member
I'm using the Responsive Lightbox & Gallery to display images on my WordPress sites.

Since enabling R2 for media storage - I've found that the lightbox doesn't open.

Actually, it's a bit strange - from the testing I've done so far, it seems that if I was to save the post while R2 for media is disabled, and then enable R2 for media, it still works.

But if I create a new post or save an existing post once R2 for media is enabled, it doesn't work - the image just loads directly rather than in the lightbox.

The way the lightbox works, you insert a WordPress image or gallery block, add images and then for each image, link it to the image file in the editor - all standard stuff. Without the lightbox, the image just loads directly in the browser.

Looking at the source code, it's clear that the data-rel that the lightbox relies on isn't being added to the media link if the post was created or saved with R2 for media enabled.

I was hoping to run the code through a debugger to see if I can identify the exact cause of the issue, but have been having difficulty given the licensing of this plugin and the fact that it's operation is tied so closely to Cloudflare.

Shawn - I was hoping perhaps you had some insight into what might be causing the issue or at least point me in the right direction so I can try and work out the issue and a potential fix?
 
With R2 for media enabled - no data-rel:

1775634328333.webp

A post created before R2 for media was enabled and so the lightroom still works

1775634401882.webp

Note that the URLs for the version that works are all the original www.example.com rather than media.example.com - I'm not sure if that is significant?

I also note the other difference is that the images that don't work (top example) include the extra ?xxxxxxx after the image URL, which again, I'm not sure is significant.

I can't see any difference in the way the post data for the images is stored in the database - it seems identical as far as I can tell.
 
Don't worry - I put Claude Code to work and had it analyse the two plugins.

It identified a regex string in the lightbox plugin that wasn't matching the cache-buster suffix that yours adds to the image URLs ?xxxxxx ... I'll suggest a patch to the author of that lightbox plugin.
 
I could probably make an option to disable cache busting, but it does seem like it would make more sense for that plugin to be able to recognize full URLs (including parameters) if they are trying to pick up URLs via regex. Alternately, if it's just a matter of the plugin using a default local URL, it may be another reason to have Cloudflare do automatic redirects (although still better to fix the root of the issue rather than rely on redirects).

 
Back
Top