Title: data-caption-title dynamically from exif data
Last modified: March 7, 2017

---

# data-caption-title dynamically from exif data

 *  Resolved [carot2016](https://wordpress.org/support/users/carot2016/)
 * (@carot2016)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/data-caption-title-dynamically-from-exif-data/)
 * Hello, all my photos are from external server, not in the WP media librairies.
   
   They all hava EXIF metadata (“ImageDescription” and “XPComment”) that we want
   to put in the caption and description.
 * I’m using exif.js to get the metatada (EXIF.getData) and then set attributes 
   like this :
 *     ```
       this.setAttribute('title', desc); // working
       this.setAttribute('data-caption-title', comment); // not working
       ```
   
 * When I inspect the element in the browser I can see that the data-caption-title
   attribute is there but we don’t see it in Foobox.
 * How can I do this.
    Thank you Caroline

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [bradvin](https://wordpress.org/support/users/bradvin/)
 * (@bradvin)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/data-caption-title-dynamically-from-exif-data/#post-8885697)
 * Hi Caroline,
 * When are you running the code above? On jQuery ready? It seems like FooBox init
   code is running before your code, so when it runs, there is no caption title 
   at that time.
 *  Thread Starter [carot2016](https://wordpress.org/support/users/carot2016/)
 * (@carot2016)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/data-caption-title-dynamically-from-exif-data/#post-8898506)
 * Hello, I add this code in the Custom Javascript (Post) in FooBox settings.
 *     ```
       $('.fbx-instance').on('foobox.beforeShow', function(e) {
           var $element = $(e.fb.item.element), //the anchor tag
               $fooboxInstance = e.fb.instance, //the foobox instance
               $modal = e.fb.instance.modal.element; //the modal object
           //your custom code goes here...
           console.log($element.data('data-caption-title'));
           e.fb.item.title = $element.data('data-caption-title');
       });
       ```
   
 * I can see in the console the data-caption-title with good info. But nothing appear
   when fooBox open.
    Caroline
 *  Thread Starter [carot2016](https://wordpress.org/support/users/carot2016/)
 * (@carot2016)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/data-caption-title-dynamically-from-exif-data/#post-8898688)
 * Resolve, I hooked on foobox.alterCaption event instead, my error.
    Very good 
   plugin, thank you.
 * Caroline

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘data-caption-title dynamically from exif data’ is closed to new replies.

 * ![](https://ps.w.org/foobox-image-lightbox/assets/icon-256x256.gif?rev=2667030)
 * [Lightbox & Modal Popup WordPress Plugin - FooBox](https://wordpress.org/plugins/foobox-image-lightbox/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/foobox-image-lightbox/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/foobox-image-lightbox/)
 * [Active Topics](https://wordpress.org/support/plugin/foobox-image-lightbox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/foobox-image-lightbox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/foobox-image-lightbox/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [carot2016](https://wordpress.org/support/users/carot2016/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/data-caption-title-dynamically-from-exif-data/#post-8898688)
 * Status: resolved