Title: a Image Slider with AngularJS
Last modified: August 22, 2016

---

# a Image Slider with AngularJS

 *  [doelpie](https://wordpress.org/support/users/doelpie/)
 * (@doelpie)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/a-image-slider-with-angularjs/)
 * I just added a button called Add Slider in Add/Edit Post Page.
 * Here’s my code in my `functions.php` :
 *  `//Add button to create slider
    add_action(‘media_buttons’,’add_my_media_button’,
   15);
 *  function add_my_media_button(){
    echo ‘<a href=”#” id=”insert-my-media” class
   =”button”>Add Slider</a>’; }
 *  function include_media_button_js_file(){
    wp_enqueue_script(‘media_button’,get_bloginfo(‘
   template_directory’).’/js/media_button.js’,array(‘jquery’),’1.0′,true); }
 *  add_action(‘wp_enqueue_media’,’include_media_button_js_file’);`
 * and this my media_button.js code
 *  `jQuery(function($){
    $(document).ready(function(){ $(‘#insert-my-media’).click(
   open_media_window); })
 *  function open_media_window(){
    if (this.window === undefined) { this.window 
   = wp.media({ title: ‘Insert a media’, library: {type:’image’}, multiple: true,
   button: {text:’Insert’} });
 *  var self = this; //needed to retrieve the function below
    this.window.on(‘select’,
   function(){ var files = self.window.state().get(‘selection’).toArray(); var values;
   for (var i = 0; i < files.length; i++) { var file = files[i].toJSON(); if(values
   ===undefined){ var values = file.url; } else{ var values = values+’,’+file.url;}};
   wp.media.editor.insert(values); }); }
 *  this.window.open();
    return false; } });`
 * after user select the pictures in media window and press Insert button it will
   add url value of pictures to content editor post box.
 * How to add this value automatically on custom fields box and add/update that 
   automatically without click add custom field button?
 * So user can add / update custom fields for that pictures url without view/ check
   custom fields to view in post editor on Screen Options in wordpress.

The topic ‘a Image Slider with AngularJS’ is closed to new replies.

## Tags

 * [angularjs](https://wordpress.org/support/topic-tag/angularjs/)
 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 0 replies
 * 1 participant
 * Last reply from: [doelpie](https://wordpress.org/support/users/doelpie/)
 * Last activity: [11 years, 4 months ago](https://wordpress.org/support/topic/a-image-slider-with-angularjs/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
