Advertisements

media_upload_image

Definition:
function media_upload_image() {}

Defined filters

  • image_send_to_editor_url
    apply_filters('image_send_to_editor_url', $html, esc_url_raw($src)

Source code

function media_upload_image() {

	$errors = array();

	$id = 0;



	if ( isset($_POST['html-upload']) && !empty($_FILES) ) {

		check_admin_referer('media-form');

		// Upload File button was clicked

		$id = media_handle_upload('async-upload', $_REQUEST['post_id']);

		unset($_FILES);

		if ( is_wp_error($id) ) {

			$errors['upload_error'] = $id;

			$id = false;

		}

	}



	if ( !empty($_POST['insertonlybutton']) ) {

		$alt = $align = '';



		$src = $_POST['insertonly']['src'];

		if ( !empty($src) && !strpos($src, '://') )

			$src = "http://$src";

		$alt = esc_attr($_POST['insertonly']['alt']);

		if ( isset($_POST['insertonly']['align']) ) {

			$align = esc_attr($_POST['insertonly']['align']);

			$class = " class='align$align'";

		}

		if ( !empty($src) )

			$html = "<img src='" . esc_url($src) . "' alt='$alt'$class />";



		$html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);

		return media_send_to_editor($html);

	}



	if ( !empty($_POST) ) {

		$return = media_upload_form_handler();



		if ( is_string($return) )

			return $return;

		if ( is_array($return) )

			$errors = $return;

	}



	if ( isset($_POST['save']) ) {

		$errors['upload_notice'] = __('Saved.');

		return media_upload_gallery();

	}



	if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )

		return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );



	return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );

}

2381

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: