How to have different captions for same image, for galleries?

Seems like I can't have the same image in different galleries with different captions. Is it possible to make that working in any way?

Like if we could change the shortcut code that Wordpress is creating when you insert a gallery. Maybe to something like this:

[gallery]
    [image 244 caption="Caption 1"]
[/gallery]

[gallery]
    [image 244 caption="Caption 2"]
[/gallery]

The best would be to get this working with Wordpress's own gallery functionality. So when you click "Insert gallery", the above code will be placed in the texteditor. Then of course also change the code that handle these shortcodes.

I have of course searched through internet for answers before writing here. Couldn't find any.

Topic shortcode captions gallery images Wordpress

Category Web


Say you have image foo.jpg and bar.jpg in your media library. foo.jpg has caption saying "foo", and bar.jpg has caption saying "bar".

Create a gallery with those two images, they will show with "foo" and "bar" captions.

Want to use them again with a different caption, but using a gallery? No problem. Make another gallery and add the two images, changing their gallery captions to say "abc" and "def".

Now, the caption of foo.jpg will be changed to "abc". But it will still show "foo" in the first gallery where it was inserted with that caption.

At least that's how it works on my test site. Newest WordPress with Gutenberg "enabled".

And the same goes for single images - caption is changed, but the caption used on a page/post remains the way it had been initially set.

I could include the links, but think it's not needed - you can easily test it yourself.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.