media_upload_type_url_form

Definition:
function media_upload_type_url_form($type = 'file', $errors = null, $id = null) {}

Parameters

  • unknown_type $type
  • unknown_type $errors
  • unknown_type $id

Defined filters

  • media_upload_form_url
    apply_filters('media_upload_form_url', $form_action_url, $type)
  • disable_captions
    apply_filters( 'disable_captions', '' )
  • $callback
    apply_filters($callback, call_user_func($callback)

Source code

function media_upload_type_url_form($type = 'file', $errors = null, $id = null) {

	media_upload_header();



	$post_id = intval($_REQUEST['post_id']);



	$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");

	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);



	$callback = "type_url_form_$type";

?>



<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form">

<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />

<?php wp_nonce_field('media-form'); ?>



<?php if ( is_callable($callback) ) { ?>



<h3 class="media-title"><?php _e('Add media file from URL'); ?></h3>



<script type="text/javascript">

//<![CDATA[

var addExtImage = {



	width : '',

	height : '',

	align : 'alignnone',



	insert : function() {

		var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = '';



		if ( '' == f.src.value || '' == t.width )

			return false;



		if ( f.title.value ) {

			title = f.title.value.replace(/'/g, ''').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');

			title = ' title="'+title+'"';

		}



		if ( f.alt.value )

			alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');



<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>

		if ( f.caption.value )

			caption = f.caption.value.replace(/'/g, ''').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');

<?php } ?>



		cls = caption ? '' : ' class="'+t.align+'"';



		html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />';



		if ( f.url.value )

			html = '<a href="'+f.url.value+'">'+html+'</a>';



		if ( caption )

			html = ''+html+'';



		var win = window.dialogArguments || opener || parent || top;

		win.send_to_editor(html);

		return false;

	},



	resetImageData : function() {

		var t = addExtImage;



		t.width = t.height = '';

		document.getElementById('go_button').style.color = '#bbb';

		if ( ! document.forms[0].src.value )

			document.getElementById('status_img').innerHTML = '*';

		else document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" alt="" />';

	},



	updateImageData : function() {

		var t = addExtImage;



		t.width = t.preloadImg.width;

		t.height = t.preloadImg.height;

		document.getElementById('go_button').style.color = '#333';

		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" alt="" />';

	},



	getImageData : function() {

		var t = addExtImage, src = document.forms[0].src.value;



		if ( ! src ) {

			t.resetImageData();

			return false;

		}

		document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />';

		t.preloadImg = new Image();

		t.preloadImg.onload = t.updateImageData;

		t.preloadImg.onerror = t.resetImageData;

		t.preloadImg.src = src;

	}

}

//]]>

</script>



<div id="media-items">

<div class="media-item media-blank">

<?php echo apply_filters($callback, call_user_func($callback)); ?>

</div>

</div>

</form>

<?php

	} else {

		wp_die( __('Unknown action.') );

	}

}

2391

About these ads

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 179 other followers

%d bloggers like this: