Title: JavaScript Error Assigning Featured Image
Last modified: May 30, 2019

---

# JavaScript Error Assigning Featured Image

 *  Resolved [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/javascript-error-assigning-featured-image/)
 * Hello,
 * I’m running into a javascript error whenever I remove and try to assign a featured
   image. I click the remove featured image button, click the set featured image
   link, and choose my image from the media library. Once the Attachment Details
   panel has opened I see groups but it’s not in a select2 as I would expect and
   I cannot select my featured image because of this. The error I get in console
   is as follows:
 *     ```
       Uncaught TypeError: jQuery(...).selectize is not a function
           at eval (eval at <anonymous> (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.2.1:2), <anonymous>:1:162)
           at eval (<anonymous>)
           at load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.2.1:2
           at Function.globalEval (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.2.1:2)
           at Ga (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.2.1:3)
           at a.fn.init.append (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils,moxiejs,plupload&ver=5.2.1:3)
           at wp.Backbone.Subviews.insert (wp-backbone.min.js?ver=5.2.1:1)
           at wp.Backbone.Subviews._attach (wp-backbone.min.js?ver=5.2.1:1)
           at wp.Backbone.Subviews.set (wp-backbone.min.js?ver=5.2.1:1)
           at wp.Backbone.Subviews.add (wp-backbone.min.js?ver=5.2.1:1)
       ```
   
 * The post is a custom post type. I’ve used the Health Check & Troubleshooting 
   plugin to narrow down the issue specifically to Groups. Let me know if you need
   further information or how I can proceed.

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

 *  Plugin Author [Kento](https://wordpress.org/support/users/proaktion/)
 * (@proaktion)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/javascript-error-assigning-featured-image/#post-11595225)
 * An update to the latest version should fix this for you.
 *  Thread Starter [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/javascript-error-assigning-featured-image/#post-11605792)
 * I’m running both the latest version of both this plugin and WordPress, Twenty
   Nineteen theme, and the following code below:
 *     ```
       /**
        * Create Post Type
        *
        * @return void
        */
       function prefix_cpt_init() {
   
       	// Slides Custom Post Type
       	register_post_type( 'cpt_slides', array(
       		'labels' 			=> 	array(
       			'name'			=>		__( 'Slides' ),
       			'singular_name'	=>		__( 'Slide' ),
       			'all_items'		=>		__( 'View Slides' ),
       			'add_new'		=>		__( 'New Slide' ),
       			'add_new_item'	=>		__( 'New Slide' ),
       			'edit_item'		=>		__( 'Edit Slide' ),
       			'view_item'		=>		__( 'View Slide' ),
       			'search_items'	=>		__( 'Search Slides' ),
       			'no_found'		=>		__( 'No Slides Found' ),
       			'not_found_in_trash' 	=>	__( 'No Slides in Trash' ),
       			'featured_image' 		=> __( 'Slide Image' ),
       			'set_featured_image' 	=> __( 'Set slide image' ),
       			'remove_featured_image' => __( 'Remove slide image' ),
       			'use_featured_image' 	=> __( 'Use as slide image' ),
       		),
       		'public'			=> 	false, 
       		'publicly_queryable'=> 	false,
       		'exclude_from_search'=>	true,
       		'show_ui' 			=> 	true, 
       		'query_var' 		=> 	false,
       		'show_in_nav_menus'	=>	false,
       		'capability_type' 	=> 	'page',
       		'hierarchical' 		=> 	false,
       		'menu_position' 	=> 	3,
       		'menu_icon'			=>	'dashicons-format-gallery',
       		'supports' 			=> 	array( 'title', 'thumbnail' )
       	) );
   
       }
       add_action( 'init', 'prefix_cpt_init' );
       ```
   
 * All plugins are disabled except Groups. I’ve gone with a re-installation of WordPress
   too. I’m open to suggestions on what else it could be.
 * – – – – – – – – –
 * **Editing plugin files to try and debug the issue**:
 * lib\views\class-groups-uie.php LN 100 if I console log jQuery and selectize, 
   it is telling me that `selectize` is undefined at this point.
 * `$call_output .= 'console.log( typeof selectize );';`
 * – – – – – – – – –
 * lib\views\class-groups-uie.php LN 70
 * If I throw in a quick test:
 * `error_log( ( ! wp_script_is( 'selectize' ) ) ? 'true' : 'false' );`
 * I get 1 false then a ton of trues but if I inspect the source ( not view source)
   and search for `selectize.min.js` it’s nowhere to be found. If I enqueue these
   scripts normally it works as expected:
 *     ```
       add_action( 'admin_enqueue_scripts', function() {
   
       	global $groups_version;
   
       	if ( !wp_script_is( 'selectize' ) ) {
       		wp_enqueue_script( 'selectize', GROUPS_PLUGIN_URL . 'js/selectize/selectize.min.js', array( 'jquery' ), $groups_version, false );
       	}
       	if ( !wp_style_is( 'selectize' ) ) {
       		wp_enqueue_style( 'selectize', GROUPS_PLUGIN_URL . 'css/selectize/selectize.bootstrap2.css', array(), $groups_version );
       	}
       	if ( !wp_style_is( 'groups-uie' ) ) {
       		wp_enqueue_style( 'groups-uie', GROUPS_PLUGIN_URL . 'css/groups-uie.css', array(), $groups_version );
       	}
   
       } );
       ```
   
 * [@proaktion](https://wordpress.org/support/users/proaktion/)
 * My guess would be that the scripts and styles are trying to be enqueued whenever
   the media frame opens but since the page is already loaded and the frame populates
   dynamically the scripts cannot be included. I imagine if I had a groups metabox
   on the page this would load just fine since the selectize script has already 
   loaded but since I **do not** have a groups metabox on this specific post type,
   no selectize has been enqueued and thus the issue occurs. Anywhere the media 
   module is needs to have selectize whether or not the Groups metabox is present.
   A simple solution would be to load selectize on admin if a selectize script isn’t
   already present.
 * Hopefully a solution for this issue can be pushed in the near future.
    -  This reply was modified 6 years, 11 months ago by [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/).
    -  This reply was modified 6 years, 11 months ago by [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/).
 *  Plugin Author [Kento](https://wordpress.org/support/users/proaktion/)
 * (@proaktion)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/javascript-error-assigning-featured-image/#post-11690692)
 * Please update to the latest version just released where this should be solved
   for you.

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

The topic ‘JavaScript Error Assigning Featured Image’ is closed to new replies.

 * ![](https://ps.w.org/groups/assets/icon-256x256.png?rev=983146)
 * [Groups](https://wordpress.org/plugins/groups/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/groups/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/groups/)
 * [Active Topics](https://wordpress.org/support/plugin/groups/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/groups/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/groups/reviews/)

## Tags

 * [featured image](https://wordpress.org/support/topic-tag/featured-image/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [js](https://wordpress.org/support/topic-tag/js/)
 * [select2](https://wordpress.org/support/topic-tag/select2/)

 * 3 replies
 * 2 participants
 * Last reply from: [Kento](https://wordpress.org/support/users/proaktion/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/javascript-error-assigning-featured-image/#post-11690692)
 * Status: resolved