I am using jQuery to convert Gutenberg gallery image to clickable lightbox image. In order to do that, I was using jQuery to get the data-full-url attribute but I just found that some images don't have this attribute.
I tried to use the srcset attribute but I couldn't find a way to chose the "right" url (the full size one) from the list of urls in jQuery.
So, is there a way to get the full image url in jQuery?
I am using jQuery to convert Gutenberg gallery image to clickable lightbox image. In order to do that, I was using jQuery to get the data-full-url attribute but I just found that some images don't have this attribute.
I tried to use the srcset attribute but I couldn't find a way to chose the "right" url (the full size one) from the list of urls in jQuery.
So, is there a way to get the full image url in jQuery?
Share Improve this question asked Jan 30, 2020 at 12:55 cyclone200cyclone200 1154 bronze badges 4 |1 Answer
Reset to default 0You can solve this problem exactly the same way you would if you were using the classic editor. Use the hyperlink href
attributes. Most lightbox libraries already do this out of the box
In order to do this, you'll need to tell the gallery to link to the media files. You can do this in the sidebar like this:
You can also register your own gallery block, then deregister the original
src
url? – Tim Elsass Commented Jan 30, 2020 at 17:17