how to upload images in wordpress by custom code?

Rate this post

Today, We want to share with you image upload custom code in wordpress.In this post we will show you wordpress frontend user image upload, hear for how to upload image in wordpress using php we will give you demo and example for implement.In this post, we will learn about custom media uploader wordpress (PHP Upload File Size Limit) with an example.

Image upload custom code in wordpress

There are the Following The simple About upload image in wordpress plugin code Full Information With Example and source code.

Read Also:  javascript replace all spaces - How to replace all spaces in a string?

As I will cover this Post with live Working example to develop image upload in wordpress, so the create custom field and upload image in wordpress is used for this example is following below.

Custom Image Upload in WordPress

in wp_enqueue_scripts hook.

dd_action( 'wp_enqueue_scripts', 'enqueue_scripts_trigger' );
function enqueue_scripts_trigger() {
    wp_enqueue_script( 'my_custom_js', 'YOUR_JS_FILE_PATH', array( 'jquery' ), '1.0', true );


<input type="button" value="Upload Profile Image" class="button-primary" id="upload_image"/>
<input type="hidden" name="attachment_id" class="wp_attachment_id" value="" /> </br>
<img src="" class="image" style="display:none;margin-top:10px;"/>

custom js

(function( $ ) {
	'use strict';

	$(function() {

		function open_custom_media_window() {
			if (this.window === undefined) {
				this.window ={
					title: 'Insert Profile Image',
					library: {type: 'image'},
					multiple: false,
					button: {text: 'Insert Profile Image'}

				var self = this;
				this.window.on('select', function() {
					var response = self.window.state().get('selection').first().toJSON();

					$('.image').attr('src', response.sizes.thumbnail.url);
			return false;
})( jQuery );

Free Live Chat for Any Issue


You can also read about AngularJS, ASP.NET, VueJs, PHP.


I hope you get an idea about image upload custom code in wordpress.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.