Title: Image attributes developer API help
Last modified: February 28, 2020

---

# Image attributes developer API help

 *  Resolved [lightningman](https://wordpress.org/support/users/lightningman/)
 * (@lightningman)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/)
 * Hi,
 * I need help with setting the title attribute of each slide in the slider to the
   post title. I have this code so far:
 *     ```
           function metaslider_add_rel_attribute_to_images($attributes, $slide, $slider_id) { 
               $attributes['title'] = get_the_title();
               return $attributes; 
           } 
           add_filter('metaslider_flex_slider_image_attributes', 'metaslider_add_rel_attribute_to_images', 10, 3);
       ```
   
 * I would appreciate any help or examples on this as I am unsure of how to properly
   call this function. Thanks!

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

 *  [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12491658)
 * Hi,
 * You likely need to pass in the post to `get_the_title()`. Have you tried outputting
   it to the page to see what is returned?
 * `echo get_the_title()`
 * You might also want to var_dump() the global $post to see if that is available.
 * let me know if that helps.
 *  Thread Starter [lightningman](https://wordpress.org/support/users/lightningman/)
 * (@lightningman)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12491716)
 * Hi,
 * Thanks for your reply. When I `echo get_the_title()` I get the post title.
 * Do I need to call this function `metaslider_add_rel_attribute_to_images()` and
   if so, which parameters do I use for `$slide` and `$attributes`? The [developer api docs](https://www.metaslider.com/documentation/metaslider_type_slider_image_attributes/)
   say it takes in an array of slide data for `$slide` but I’m not sure what that
   refers to.
 * Thanks
 *  [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12491724)
 * You’re doing it right. What’s the image title showing?
 *  Thread Starter [lightningman](https://wordpress.org/support/users/lightningman/)
 * (@lightningman)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12492053)
 * I’m getting the correct image title but now it only shows one slide, not the 
   whole slideshow
 *  [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12493133)
 * Hi,
 * That could be many things. Do you see any errors in the browser console? If you
   can share a link I can take a look.
 *  Thread Starter [lightningman](https://wordpress.org/support/users/lightningman/)
 * (@lightningman)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12499653)
 * Hi,
 * I didn’t receive any errors in the console. However, I was able to get it working.
 * My last question is what indicates where the `add_filter` will be echoed? For
   instance, I had the default `<?php do_shortcode ?>` with my slider ID originally,
   but then the `add_filter` generated another slider at the bottom of the page.
   How do I control where on the page this is generated or should I stick with the`
   do_shortcode` but hide the duplicate slider somehow? Hope this makes sense.
 * Thanks!
 *  [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * (@kbat82)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12499745)
 * Hi,
 * You shouldn’t be using add_filter to echo or show any code. It should only be
   used to filter data as it passes through the application.
 * I’ll mark this issue as resolved but feel free to continue replying.

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

The topic ‘Image attributes developer API help’ is closed to new replies.

 * ![](https://ps.w.org/ml-slider/assets/icon.svg?rev=3523572)
 * [Slider, Gallery, and Carousel by MetaSlider - Image Slider, Video Slider](https://wordpress.org/plugins/ml-slider/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ml-slider/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ml-slider/)
 * [Active Topics](https://wordpress.org/support/plugin/ml-slider/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ml-slider/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ml-slider/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Kevin Batdorf](https://wordpress.org/support/users/kbat82/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/image-attributes-developer-api-help/#post-12499745)
 * Status: resolved