Just ran into a problem where captions are being reapplied multiple times when using colorbox. I created a 60 second screen cast demoing the problem.

http://www.screencast-o-matic.com/watch/cXfOFYDLC

One solution could be to add a check to the JS to see if the captioning is already set, if so then don't reapply it.

Comments

davidwhthomas’s picture

Status: Active » Needs work

Thanks for the bug report. I've seen similar issues before on other modules.
It occurs because the drupal.behavior function is run after each js-triggered DOM change.
This is good, if for example the image is added via javascript/ajax and you want it captioned, but not so good in this case where the caption in duplicated.
I'll add a 'caption-processed' class to images already captioned, and check that in the js, which will prevent this occurring.

bryancasler’s picture

Couldn't you save the extra class and just check for "image-caption-container". Not that it matters, but I was just wondering if there is another reason to do the previous vs the latter.

davidwhthomas’s picture

Something to that effect would also suffice however the Drupal convention seems to be to use a foo-processed class for such instances.

bryancasler’s picture

thanks for letting me pick your brain

davidwhthomas’s picture

Status: Needs work » Needs review

@animelion, I've added the caption-processed support to a new beta3 release, please update, test and confirm working for you too, thanks.

bryancasler’s picture

Works like a charm.

rooby’s picture

Status: Needs review » Fixed

Seems fixed to me.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 834b5e9 on master, 7.x-1.x by davidwhthomas:
    #1139112 prevent caption duplication on DOM change
    
    
balazsgabi’s picture

Issue summary: View changes

I have downloaded the latest stable version (7.x-2.8) and I found that also. After closing overlay and the page of refresh disappear the multiplicates.

update: sorry this irrelevant here, I am confusioned in my browser tabs. Consider to be superfluous.