Open rizedr opened 8 years ago
Actually the image does add, and if you look with inspector the value of the input field will change, its just that the thumbnail is not being displayed anymore because the container was deleted, and there was nothing written to handle re-adding it.
The changes need to happen in the /assets/settings.js file, but then this file should be minified, and the /assets/settings.min.js contents replaced (if you don't do this step it won't work!).
So, in /assets/settings.js change:
Line: 52
jQuery("#"+preview_id).attr('src',attachment.sizes.thumbnail.url);
To:
jQuery("#"+preview_id).attr('src',attachment.sizes.thumbnail.url).show();
Line: 67
jQuery(this).closest('td').find( '.image_preview' ).remove();
To:
jQuery(this).closest('td').find( '.image_preview' ).hide();
Please note that wordpress caches admin javascript files, so it is advisable to add some cache busting for a development of a wordpress plugin, i.e. in /includes/class-your-plugin.php
around 190, change:
public function admin_enqueue_scripts ( $hook = '' ) { wp_register_script( $this->_token . '-admin', esc_url( $this->assets_url ) . 'js/admin' . $this->script_suffix . '.js', array( 'jquery' ), $this->_version ); wp_enqueue_script( $this->_token . '-admin' ); } // End admin_enqueue_scripts ()
to:
public function admin_enqueue_scripts ( $hook = '' ) { wp_register_script( $this->_token . '-admin', esc_url( $this->assets_url ) . 'js/admin' . $this->script_suffix . '.js?t='.time(), array( 'jquery' ), $this->_version ); wp_enqueue_script( $this->_token . '-admin' ); } // End admin_enqueue_scripts ()
First of all, go in the plugin's settings page. The following steps are to reproduce the issue: