While working fine when using jQuery 1.5, I got a TypeError when using jQuery 1.7 (or 1.8 for that matter). In line 57 of jcaption.js the script checks to see if there is content for the caption. If not, cleanimage.attr(settings.imageAttr) is undefined, hence the error. Apparently this didn't cause an error in previous versions of jQuery (is it defined elsewhere?). A quick fix is to change line 57 to:

if( cleanimage.attr(settings.imageAttr) != undefined && (cleanimage.attr(settings.imageAttr).length > 0 || !settings.requireText)){

There is probably a better (cleaner) way of fixing this. I think for the future of this module it would be important to work with jQuery 1.7+ so it might be worth looking into.

Thanks!

Leon

Comments

billyroebuck’s picture

Thanks Leon, this helped me. In my case the issue was happening intermittently, but this seems to have fixed it. I'm not a fan of modifying module code but I am not sure how we'd go about creating a patch/etc. Thanks a lot for posting this!

acke’s picture

Issue summary: View changes
Status: Active » Fixed

Good catch! Committed and pushed to HEAD / 7.x-1.x-dev and going into 1.4 release. Thanks for making jcaption better!

Status: Fixed » Closed (fixed)

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