Skip to main content

Try using this code:-

define("ME_URL", rtrim(WP_PLUGIN_URL,'/') . '/' . basename(dirname(__FILE__)) );
define("ME_DIR", rtrim(dirname(__FILE__), '/'));
    
function my_admin_scripts() {
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
}
    
function my_admin_styles() {
    wp_enqueue_style('thickbox');
}
    
add_action('admin_print_scripts', 'my_admin_scripts');
add_action('admin_print_styles', 'my_admin_styles');
 
 
<td>
  <img  <img src="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" id="ppimage">
    <input type="text" name="profileimage" id="profileimagetxt" value="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" class="regular-text" /><br />
    <input type="button" id="profileimage" value="Upload Image">
    <span class="description"><?php _e("profileimage"); ?></span>
</td>
</tr>
<script type="text/javascript">
    $ = jQuery.noConflict();
    $(document).ready(function($){
 
      $('#profileimage').live('click',function() {
        formfield = $('#upload_image').attr('name');
        tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
 
        return false;
      });
    
      window.send_to_editor = function(html) {
        imgurl = $('img',html).attr('src');
        $('#profileimagetxt').val(imgurl);
        $('#ppimage').attr('src',imgurl);
        tb_remove();
      }
    });<;
</script>

Hope it works for you :)

Try using this code:-

define("ME_URL", rtrim(WP_PLUGIN_URL,'/') . '/'.basename(dirname(__FILE__)) );
define("ME_DIR", rtrim(dirname(__FILE__), '/'));

function my_admin_scripts() {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
}

function my_admin_styles() {
wp_enqueue_style('thickbox');
}

add_action('admin_print_scripts', 'my_admin_scripts');
add_action('admin_print_styles', 'my_admin_styles');
 
<td>
  <img  src="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" id="ppimage">
<input type="text" name="profileimage" id="profileimagetxt" value="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" class="regular-text" /><br />
<input type="button" id="profileimage" value="Upload Image">
<span class="description"><?php _e("profileimage"); ?></span>
</td>
</tr>
<script type="text/javascript">
$ = jQuery.noConflict();
$(document).ready(function($){
 
  $('#profileimage').live('click',function() {
formfield = $('#upload_image').attr('name');
tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
 
return false;
});

window.send_to_editor = function(html) {
imgurl = $('img',html).attr('src');
$('#profileimagetxt').val(imgurl);
$('#ppimage').attr('src',imgurl);
tb_remove();
}
});</script>

Hope it works for you :)

Try using this code:

define("ME_URL", rtrim(WP_PLUGIN_URL,'/') . '/' . basename(dirname(__FILE__)));
define("ME_DIR", rtrim(dirname(__FILE__), '/'));
    
function my_admin_scripts() {
    wp_enqueue_script('media-upload');
    wp_enqueue_script('thickbox');
}
    
function my_admin_styles() {
    wp_enqueue_style('thickbox');
}
    
add_action('admin_print_scripts', 'my_admin_scripts');
add_action('admin_print_styles', 'my_admin_styles');
 
<td>
    <img src="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" id="ppimage">
    <input type="text" name="profileimage" id="profileimagetxt" value="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" class="regular-text" /><br />
    <input type="button" id="profileimage" value="Upload Image">
    <span class="description"><?php _e("profileimage"); ?></span>
</td>
</tr>
<script type="text/javascript">
    $ = jQuery.noConflict();
    $(document).ready(function($){
      $('#profileimage').live('click',function() {
        formfield = $('#upload_image').attr('name');
        tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
        return false;
      });
    
      window.send_to_editor = function(html) {
        imgurl = $('img',html).attr('src');
        $('#profileimagetxt').val(imgurl);
        $('#ppimage').attr('src',imgurl);
        tb_remove();
      }
    });
</script>

Hope it works for you :)

Source Link
dev
  • 301
  • 1
  • 7

Try using this code:-

define("ME_URL", rtrim(WP_PLUGIN_URL,'/') . '/'.basename(dirname(__FILE__)) );
define("ME_DIR", rtrim(dirname(__FILE__), '/'));

function my_admin_scripts() {
wp_enqueue_script('media-upload');
wp_enqueue_script('thickbox');
}

function my_admin_styles() {
wp_enqueue_style('thickbox');
}

add_action('admin_print_scripts', 'my_admin_scripts');
add_action('admin_print_styles', 'my_admin_styles');

<td>
  <img  src="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" id="ppimage">
<input type="text" name="profileimage" id="profileimagetxt" value="<?php echo esc_attr( get_the_author_meta( 'profileimage', $user->ID ) ); ?>" class="regular-text" /><br />
<input type="button" id="profileimage" value="Upload Image">
<span class="description"><?php _e("profileimage"); ?></span>
</td>
</tr>
<script type="text/javascript">
$ = jQuery.noConflict();
$(document).ready(function($){

  $('#profileimage').live('click',function() {
formfield = $('#upload_image').attr('name');
tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');

return false;
});

window.send_to_editor = function(html) {
imgurl = $('img',html).attr('src');
$('#profileimagetxt').val(imgurl);
$('#ppimage').attr('src',imgurl);
tb_remove();
}
});</script>

Hope it works for you :)