web/wp-admin/includes/media.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    38 	if ( !isset($_REQUEST['post_id']) ) {
    38 	if ( !isset($_REQUEST['post_id']) ) {
    39 		unset($tabs['gallery']);
    39 		unset($tabs['gallery']);
    40 		return $tabs;
    40 		return $tabs;
    41 	}
    41 	}
    42 
    42 
    43 	if ( intval($_REQUEST['post_id']) )
    43 	$post_id = intval($_REQUEST['post_id']);
    44 		$attachments = intval($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $_REQUEST['post_id'])));
    44 
       
    45 	if ( $post_id )
       
    46 		$attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) );
    45 
    47 
    46 	if ( empty($attachments) ) {
    48 	if ( empty($attachments) ) {
    47 		unset($tabs['gallery']);
    49 		unset($tabs['gallery']);
    48 		return $tabs;
    50 		return $tabs;
    49 	}
    51 	}
    96  * @param unknown_type $url
    98  * @param unknown_type $url
    97  * @param unknown_type $rel
    99  * @param unknown_type $rel
    98  * @param unknown_type $size
   100  * @param unknown_type $size
    99  * @return unknown
   101  * @return unknown
   100  */
   102  */
   101 function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') {
   103 function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = false, $size='medium', $alt = '') {
   102 
   104 
   103 	$htmlalt = ( empty($alt) ) ? $title : $alt;
   105 	$html = get_image_tag($id, $alt, $title, $align, $size);
   104 
       
   105 	$html = get_image_tag($id, $htmlalt, $title, $align, $size);
       
   106 
   106 
   107 	$rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : '';
   107 	$rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : '';
   108 
   108 
   109 	if ( $url )
   109 	if ( $url )
   110 		$html = '<a href="' . esc_url($url) . "\"$rel>$html</a>";
   110 		$html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>";
   111 
   111 
   112 	$html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url, $size );
   112 	$html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt );
   113 
   113 
   114 	return $html;
   114 	return $html;
   115 }
   115 }
   116 
   116 
   117 /**
   117 /**
   126  * @param unknown_type $align
   126  * @param unknown_type $align
   127  * @param unknown_type $url
   127  * @param unknown_type $url
   128  * @param unknown_type $size
   128  * @param unknown_type $size
   129  * @return unknown
   129  * @return unknown
   130  */
   130  */
   131 function image_add_caption( $html, $id, $alt, $title, $align, $url, $size ) {
   131 function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) {
   132 
   132 
   133 	if ( empty($alt) || apply_filters( 'disable_captions', '' ) )
   133 	if ( empty($caption) || apply_filters( 'disable_captions', '' ) )
   134 		return $html;
   134 		return $html;
   135 
   135 
   136 	$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
   136 	$id = ( 0 < (int) $id ) ? 'attachment_' . $id : '';
   137 
   137 
   138 	preg_match( '/width="([0-9]+)/', $html, $matches );
   138 	if ( ! preg_match( '/width="([0-9]+)/', $html, $matches ) )
   139 	if ( ! isset($matches[1]) )
       
   140 		return $html;
   139 		return $html;
   141 
   140 
   142 	$width = $matches[1];
   141 	$width = $matches[1];
   143 
   142 
   144 	$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
   143 	$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html );
   145 	if ( empty($align) )
   144 	if ( empty($align) )
   146 		$align = 'none';
   145 		$align = 'none';
   147 
   146 
   148 	$alt = ! empty($alt) ? addslashes($alt) : '';
       
   149 
       
   150 	$shcode = '[caption id="' . $id . '" align="align' . $align
   147 	$shcode = '[caption id="' . $id . '" align="align' . $align
   151 	. '" width="' . $width . '" caption="' . $alt . '"]' . $html . '[/caption]';
   148 	. '" width="' . $width . '" caption="' . addslashes($caption) . '"]' . $html . '[/caption]';
   152 
   149 
   153 	return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
   150 	return apply_filters( 'image_add_caption_shortcode', $shcode, $html );
   154 }
   151 }
   155 add_filter( 'image_send_to_editor', 'image_add_caption', 20, 7 );
   152 add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 );
   156 
   153 
   157 /**
   154 /**
   158  * {@internal Missing Short Description}}
   155  * {@internal Missing Short Description}}
   159  *
   156  *
   160  * @since unknown
   157  * @since unknown
   167 /* <![CDATA[ */
   164 /* <![CDATA[ */
   168 var win = window.dialogArguments || opener || parent || top;
   165 var win = window.dialogArguments || opener || parent || top;
   169 win.send_to_editor('<?php echo addslashes($html); ?>');
   166 win.send_to_editor('<?php echo addslashes($html); ?>');
   170 /* ]]> */
   167 /* ]]> */
   171 </script>
   168 </script>
   172 	<?php
   169 <?php
   173 	exit;
   170 	exit;
   174 }
   171 }
   175 
   172 
   176 /**
   173 /**
   177  * {@internal Missing Short Description}}
   174  * {@internal Missing Short Description}}
   247  * @param unknown_type $post_data
   244  * @param unknown_type $post_data
   248  * @return unknown
   245  * @return unknown
   249  */
   246  */
   250 function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
   247 function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) {
   251 	$overrides = array('test_form'=>false);
   248 	$overrides = array('test_form'=>false);
       
   249 
   252 	$file = wp_handle_sideload($file_array, $overrides);
   250 	$file = wp_handle_sideload($file_array, $overrides);
   253 
       
   254 	if ( isset($file['error']) )
   251 	if ( isset($file['error']) )
   255 		return new WP_Error( 'upload_error', $file['error'] );
   252 		return new WP_Error( 'upload_error', $file['error'] );
   256 
   253 
   257 	$url = $file['url'];
   254 	$url = $file['url'];
   258 	$type = $file['type'];
   255 	$type = $file['type'];
   277 		'post_parent' => $post_id,
   274 		'post_parent' => $post_id,
   278 		'post_title' => $title,
   275 		'post_title' => $title,
   279 		'post_content' => $content,
   276 		'post_content' => $content,
   280 	), $post_data );
   277 	), $post_data );
   281 
   278 
   282 	// Save the data
   279 	// Save the attachment metadata
   283 	$id = wp_insert_attachment($attachment, $file, $post_id);
   280 	$id = wp_insert_attachment($attachment, $file, $post_id);
   284 	if ( !is_wp_error($id) ) {
   281 	if ( !is_wp_error($id) ) {
   285 		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
   282 		wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
   286 		return $url;
   283 		return $url;
   287 	}
   284 	}
   314 wp_enqueue_style( 'ie' );
   311 wp_enqueue_style( 'ie' );
   315 ?>
   312 ?>
   316 <script type="text/javascript">
   313 <script type="text/javascript">
   317 //<![CDATA[
   314 //<![CDATA[
   318 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
   315 addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
   319 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time() ?>'};
   316 var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'};
       
   317 var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup';
   320 //]]>
   318 //]]>
   321 </script>
   319 </script>
   322 <?php
   320 <?php
       
   321 do_action('admin_enqueue_scripts', 'media-upload-popup');
       
   322 do_action('admin_print_styles-media-upload-popup');
   323 do_action('admin_print_styles');
   323 do_action('admin_print_styles');
       
   324 do_action('admin_print_scripts-media-upload-popup');
   324 do_action('admin_print_scripts');
   325 do_action('admin_print_scripts');
       
   326 do_action('admin_head-media-upload-popup');
   325 do_action('admin_head');
   327 do_action('admin_head');
       
   328 
   326 if ( is_string($content_func) )
   329 if ( is_string($content_func) )
   327 	do_action( "admin_head_{$content_func}" );
   330 	do_action( "admin_head_{$content_func}" );
   328 ?>
   331 ?>
   329 </head>
   332 </head>
   330 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
   333 <body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?>>
   403 				$post['post_parent'] = $attachment['post_parent'];
   406 				$post['post_parent'] = $attachment['post_parent'];
   404 		}
   407 		}
   405 
   408 
   406 		$post = apply_filters('attachment_fields_to_save', $post, $attachment);
   409 		$post = apply_filters('attachment_fields_to_save', $post, $attachment);
   407 
   410 
       
   411 		if ( isset($attachment['image_alt']) && !empty($attachment['image_alt']) ) {
       
   412 			$image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true);
       
   413 			if ( $image_alt != stripslashes($attachment['image_alt']) ) {
       
   414 				$image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true );
       
   415 				// update_meta expects slashed
       
   416 				update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) );
       
   417 			}
       
   418 		}
       
   419 
   408 		if ( isset($post['errors']) ) {
   420 		if ( isset($post['errors']) ) {
   409 			$errors[$attachment_id] = $post['errors'];
   421 			$errors[$attachment_id] = $post['errors'];
   410 			unset($post['errors']);
   422 			unset($post['errors']);
   411 		}
   423 		}
   412 
   424 
   413 		if ( $post != $_post )
   425 		if ( $post != $_post )
   414 			wp_update_post($post);
   426 			wp_update_post($post);
   415 
   427 
   416 		foreach ( get_attachment_taxonomies($post) as $t )
   428 		foreach ( get_attachment_taxonomies($post) as $t ) {
   417 			if ( isset($attachment[$t]) )
   429 			if ( isset($attachment[$t]) )
   418 				wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
   430 				wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
       
   431 		}
   419 	}
   432 	}
   420 
   433 
   421 	if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
   434 	if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
   422 		<script type="text/javascript">
   435 		<script type="text/javascript">
   423 		/* <![CDATA[ */
   436 		/* <![CDATA[ */
   466 			$id = false;
   479 			$id = false;
   467 		}
   480 		}
   468 	}
   481 	}
   469 
   482 
   470 	if ( !empty($_POST['insertonlybutton']) ) {
   483 	if ( !empty($_POST['insertonlybutton']) ) {
       
   484 		$alt = $align = '';
       
   485 
   471 		$src = $_POST['insertonly']['src'];
   486 		$src = $_POST['insertonly']['src'];
   472 		if ( !empty($src) && !strpos($src, '://') )
   487 		if ( !empty($src) && !strpos($src, '://') )
   473 			$src = "http://$src";
   488 			$src = "http://$src";
   474 		$alt = esc_attr($_POST['insertonly']['alt']);
   489 		$alt = esc_attr($_POST['insertonly']['alt']);
   475 		if ( isset($_POST['insertonly']['align']) ) {
   490 		if ( isset($_POST['insertonly']['align']) ) {
   476 			$align = esc_attr($_POST['insertonly']['align']);
   491 			$align = esc_attr($_POST['insertonly']['align']);
   477 			$class = " class='align$align'";
   492 			$class = " class='align$align'";
   478 		}
   493 		}
   479 		if ( !empty($src) )
   494 		if ( !empty($src) )
   480 			$html = "<img src='$src' alt='$alt'$class />";
   495 			$html = "<img src='" . esc_url($src) . "' alt='$alt'$class />";
   481 		$html = apply_filters('image_send_to_editor_url', $html, $src, $alt, $align);
   496 
       
   497 		$html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align);
   482 		return media_send_to_editor($html);
   498 		return media_send_to_editor($html);
   483 	}
   499 	}
   484 
   500 
   485 	if ( !empty($_POST) ) {
   501 	if ( !empty($_POST) ) {
   486 		$return = media_upload_form_handler();
   502 		$return = media_upload_form_handler();
   512  * @param unknown_type $desc
   528  * @param unknown_type $desc
   513  * @return unknown
   529  * @return unknown
   514  */
   530  */
   515 function media_sideload_image($file, $post_id, $desc = null) {
   531 function media_sideload_image($file, $post_id, $desc = null) {
   516 	if (!empty($file) ) {
   532 	if (!empty($file) ) {
   517 		$file_array['name'] = basename($file);
   533 		// Download file to temp location
   518 		$tmp = download_url($file);
   534 		$tmp = download_url($file);
       
   535 
       
   536 		// Set variables for storage
       
   537 		// fix file filename for query strings
       
   538 		preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $file, $matches);
       
   539 		$file_array['name'] = basename($matches[0]);
   519 		$file_array['tmp_name'] = $tmp;
   540 		$file_array['tmp_name'] = $tmp;
   520 		$desc = @$desc;
   541 
   521 
   542 		// If error storing temporarily, unlink
   522 		if ( is_wp_error($tmp) ) {
   543 		if ( is_wp_error($tmp) ) {
   523 			@unlink($file_array['tmp_name']);
   544 			@unlink($file_array['tmp_name']);
   524 			$file_array['tmp_name'] = '';
   545 			$file_array['tmp_name'] = '';
   525 		}
   546 		}
   526 
   547 
   527 		$id = media_handle_sideload($file_array, $post_id, $desc);
   548 		// do the validation and storage stuff
       
   549 		$id = media_handle_sideload($file_array, $post_id, @$desc);
   528 		$src = $id;
   550 		$src = $id;
   529 
   551 
       
   552 		// If error storing permanently, unlink
   530 		if ( is_wp_error($id) ) {
   553 		if ( is_wp_error($id) ) {
   531 			@unlink($file_array['tmp_name']);
   554 			@unlink($file_array['tmp_name']);
   532 			return $id;
   555 			return $id;
   533 		}
   556 		}
   534 	}
   557 	}
   535 
   558 
       
   559 	// Finally check to make sure the file has been saved, then return the html
   536 	if ( !empty($src) ) {
   560 	if ( !empty($src) ) {
   537 		$alt = @$desc;
   561 		$alt = @$desc;
   538 		$html = "<img src='$src' alt='$alt' />";
   562 		$html = "<img src='$src' alt='$alt' />";
   539 		return $html;
   563 		return $html;
   540 	}
   564 	}
   563 
   587 
   564 	if ( !empty($_POST['insertonlybutton']) ) {
   588 	if ( !empty($_POST['insertonlybutton']) ) {
   565 		$href = $_POST['insertonly']['href'];
   589 		$href = $_POST['insertonly']['href'];
   566 		if ( !empty($href) && !strpos($href, '://') )
   590 		if ( !empty($href) && !strpos($href, '://') )
   567 			$href = "http://$href";
   591 			$href = "http://$href";
       
   592 
   568 		$title = esc_attr($_POST['insertonly']['title']);
   593 		$title = esc_attr($_POST['insertonly']['title']);
   569 		if ( empty($title) )
   594 		if ( empty($title) )
   570 			$title = basename($href);
   595             $title = esc_attr( basename($href) );
       
   596 
   571 		if ( !empty($title) && !empty($href) )
   597 		if ( !empty($title) && !empty($href) )
   572 			$html = "<a href='$href' >$title</a>";
   598             $html = "<a href='" . esc_url($href) . "' >$title</a>";
       
   599 
   573 		$html = apply_filters('audio_send_to_editor_url', $html, $href, $title);
   600 		$html = apply_filters('audio_send_to_editor_url', $html, $href, $title);
       
   601 
   574 		return media_send_to_editor($html);
   602 		return media_send_to_editor($html);
   575 	}
   603 	}
   576 
   604 
   577 	if ( !empty($_POST) ) {
   605 	if ( !empty($_POST) ) {
   578 		$return = media_upload_form_handler();
   606 		$return = media_upload_form_handler();
   617 
   645 
   618 	if ( !empty($_POST['insertonlybutton']) ) {
   646 	if ( !empty($_POST['insertonlybutton']) ) {
   619 		$href = $_POST['insertonly']['href'];
   647 		$href = $_POST['insertonly']['href'];
   620 		if ( !empty($href) && !strpos($href, '://') )
   648 		if ( !empty($href) && !strpos($href, '://') )
   621 			$href = "http://$href";
   649 			$href = "http://$href";
       
   650 
   622 		$title = esc_attr($_POST['insertonly']['title']);
   651 		$title = esc_attr($_POST['insertonly']['title']);
   623 		if ( empty($title) )
   652         if ( empty($title) )
   624 			$title = basename($href);
   653             $title = esc_attr( basename($href) );
       
   654 
   625 		if ( !empty($title) && !empty($href) )
   655 		if ( !empty($title) && !empty($href) )
   626 			$html = "<a href='$href' >$title</a>";
   656             $html = "<a href='" . esc_url($href) . "' >$title</a>";
       
   657 
   627 		$html = apply_filters('video_send_to_editor_url', $html, $href, $title);
   658 		$html = apply_filters('video_send_to_editor_url', $html, $href, $title);
       
   659 
   628 		return media_send_to_editor($html);
   660 		return media_send_to_editor($html);
   629 	}
   661 	}
   630 
   662 
   631 	if ( !empty($_POST) ) {
   663 	if ( !empty($_POST) ) {
   632 		$return = media_upload_form_handler();
   664 		$return = media_upload_form_handler();
   671 
   703 
   672 	if ( !empty($_POST['insertonlybutton']) ) {
   704 	if ( !empty($_POST['insertonlybutton']) ) {
   673 		$href = $_POST['insertonly']['href'];
   705 		$href = $_POST['insertonly']['href'];
   674 		if ( !empty($href) && !strpos($href, '://') )
   706 		if ( !empty($href) && !strpos($href, '://') )
   675 			$href = "http://$href";
   707 			$href = "http://$href";
       
   708 
   676 		$title = esc_attr($_POST['insertonly']['title']);
   709 		$title = esc_attr($_POST['insertonly']['title']);
   677 		if ( empty($title) )
   710 		if ( empty($title) )
   678 			$title = basename($href);
   711 			$title = basename($href);
   679 		if ( !empty($title) && !empty($href) )
   712 		if ( !empty($title) && !empty($href) )
   680 			$html = "<a href='$href' >$title</a>";
   713 			$html = "<a href='" . esc_url($href) . "' >$title</a>";
   681 		$html = apply_filters('file_send_to_editor_url', $html, $href, $title);
   714 		$html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
   682 		return media_send_to_editor($html);
   715 		return media_send_to_editor($html);
   683 	}
   716 	}
   684 
   717 
   685 	if ( !empty($_POST) ) {
   718 	if ( !empty($_POST) ) {
   686 		$return = media_upload_form_handler();
   719 		$return = media_upload_form_handler();
   755  * @param unknown_type $checked
   788  * @param unknown_type $checked
   756  * @return unknown
   789  * @return unknown
   757  */
   790  */
   758 function image_align_input_fields( $post, $checked = '' ) {
   791 function image_align_input_fields( $post, $checked = '' ) {
   759 
   792 
       
   793 	if ( empty($checked) )
       
   794 		$checked = get_user_setting('align', 'none');
       
   795 
   760 	$alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right'));
   796 	$alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right'));
   761 	if ( !array_key_exists( (string) $checked, $alignments ) )
   797 	if ( !array_key_exists( (string) $checked, $alignments ) )
   762 		$checked = 'none';
   798 		$checked = 'none';
   763 
   799 
   764 	$out = array();
   800 	$out = array();
   765 	foreach ($alignments as $name => $label) {
   801 	foreach ( $alignments as $name => $label ) {
   766 		$name = esc_attr($name);
   802 		$name = esc_attr($name);
   767 		$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'".
   803 		$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'".
   768 		 	( $checked == $name ? " checked='checked'" : "" ) .
   804 		 	( $checked == $name ? " checked='checked'" : "" ) .
   769 			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>" . $label . "</label>";
   805 			" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>";
   770 	}
   806 	}
   771 	return join("\n", $out);
   807 	return join("\n", $out);
   772 }
   808 }
   773 
   809 
   774 /**
   810 /**
   778  *
   814  *
   779  * @param unknown_type $post
   815  * @param unknown_type $post
   780  * @param unknown_type $checked
   816  * @param unknown_type $checked
   781  * @return unknown
   817  * @return unknown
   782  */
   818  */
   783 function image_size_input_fields( $post, $checked = '' ) {
   819 function image_size_input_fields( $post, $check = '' ) {
   784 
   820 
   785 		// get a list of the actual pixel dimensions of each possible intermediate version of this image
   821 		// get a list of the actual pixel dimensions of each possible intermediate version of this image
   786 		$size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size'));
   822 		$size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size'));
   787 
   823 
   788 		foreach ( $size_names as $size => $name ) {
   824 		if ( empty($check) )
       
   825 			$check = get_user_setting('imgsize', 'medium');
       
   826 
       
   827 		foreach ( $size_names as $size => $label ) {
   789 			$downsize = image_downsize($post->ID, $size);
   828 			$downsize = image_downsize($post->ID, $size);
       
   829 			$checked = '';
   790 
   830 
   791 			// is this size selectable?
   831 			// is this size selectable?
   792 			$enabled = ( $downsize[3] || 'full' == $size );
   832 			$enabled = ( $downsize[3] || 'full' == $size );
   793 			$css_id = "image-size-{$size}-{$post->ID}";
   833 			$css_id = "image-size-{$size}-{$post->ID}";
   794 			// if this size is the default but that's not available, don't select it
   834 			// if this size is the default but that's not available, don't select it
   795 			if ( $checked && !$enabled )
   835 			if ( $size == $check ) {
   796 				$checked = '';
   836 				if ( $enabled )
   797 			// if $checked was not specified, default to the first available size that's bigger than a thumbnail
   837 					$checked = " checked='checked'";
   798 			if ( !$checked && $enabled && 'thumbnail' != $size )
   838 				else
   799 				$checked = $size;
   839 					$check = '';
   800 
   840 			} elseif ( !$check && $enabled && 'thumbnail' != $size ) {
   801 			$html = "<div class='image-size-item'><input type='radio' ".( $enabled ? '' : "disabled='disabled'")."name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'".( $checked == $size ? " checked='checked'" : '') ." />";
   841 				// if $check is not enabled, default to the first available size that's bigger than a thumbnail
   802 
   842 				$check = $size;
   803 			$html .= "<label for='{$css_id}'>" . __($name). "</label>";
   843 				$checked = " checked='checked'";
       
   844 			}
       
   845 
       
   846 			$html = "<div class='image-size-item'><input type='radio' " . ( $enabled ? '' : "disabled='disabled' " ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
       
   847 
       
   848 			$html .= "<label for='{$css_id}'>$label</label>";
   804 			// only show the dimensions if that choice is available
   849 			// only show the dimensions if that choice is available
   805 			if ( $enabled )
   850 			if ( $enabled )
   806 				$html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d&nbsp;&times;&nbsp;%d)"), $downsize[1], $downsize[2] ). "</label>";
   851 				$html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d&nbsp;&times;&nbsp;%d)"), $downsize[1], $downsize[2] ). "</label>";
   807 
   852 
   808 			$html .= '</div>';
   853 			$html .= '</div>';
   824  *
   869  *
   825  * @param unknown_type $post
   870  * @param unknown_type $post
   826  * @param unknown_type $url_type
   871  * @param unknown_type $url_type
   827  * @return unknown
   872  * @return unknown
   828  */
   873  */
   829 function image_link_input_fields($post, $url_type='') {
   874 function image_link_input_fields($post, $url_type = '') {
   830 
   875 
   831 	$file = wp_get_attachment_url($post->ID);
   876 	$file = wp_get_attachment_url($post->ID);
   832 	$link = get_attachment_link($post->ID);
   877 	$link = get_attachment_link($post->ID);
       
   878 
       
   879 	if ( empty($url_type) )
       
   880 		$url_type = get_user_setting('urlbutton', 'post');
   833 
   881 
   834 	$url = '';
   882 	$url = '';
   835 	if ( $url_type == 'file' )
   883 	if ( $url_type == 'file' )
   836 		$url = $file;
   884 		$url = $file;
   837 	elseif ( $url_type == 'post' )
   885 	elseif ( $url_type == 'post' )
   838 		$url = $link;
   886 		$url = $link;
   839 
   887 
   840 	return "<input type='text' class='urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br />
   888 	return "
   841 				<button type='button' class='button urlnone' title=''>" . __('None') . "</button>
   889 	<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br />
   842 				<button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button>
   890 	<button type='button' class='button urlnone' title=''>" . __('None') . "</button>
   843 				<button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Post URL') . "</button>
   891 	<button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button>
       
   892 	<button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Post URL') . "</button>
   844 ";
   893 ";
   845 }
   894 }
   846 
   895 
   847 /**
   896 /**
   848  * {@internal Missing Short Description}}
   897  * {@internal Missing Short Description}}
   853  * @param unknown_type $post
   902  * @param unknown_type $post
   854  * @return unknown
   903  * @return unknown
   855  */
   904  */
   856 function image_attachment_fields_to_edit($form_fields, $post) {
   905 function image_attachment_fields_to_edit($form_fields, $post) {
   857 	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
   906 	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
       
   907 		$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true);
       
   908 		if ( empty($alt) )
       
   909 			$alt = '';
       
   910 
   858 		$form_fields['post_title']['required'] = true;
   911 		$form_fields['post_title']['required'] = true;
   859 		$file = wp_get_attachment_url($post->ID);
   912 
   860 
   913 		$form_fields['image_alt'] = array(
   861 		$form_fields['image_url']['value'] = $file;
   914 			'value' => $alt,
   862 
   915 			'label' => __('Alternate text'),
   863 		$form_fields['post_excerpt']['label'] = __('Caption');
   916 			'helps' => __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;')
   864 		$form_fields['post_excerpt']['helps'][] = __('Also used as alternate text for the image');
   917 		);
   865 
       
   866 		$form_fields['post_content']['label'] = __('Description');
       
   867 
   918 
   868 		$form_fields['align'] = array(
   919 		$form_fields['align'] = array(
   869 			'label' => __('Alignment'),
   920 			'label' => __('Alignment'),
   870 			'input' => 'html',
   921 			'input' => 'html',
   871 			'html'  => image_align_input_fields($post, get_option('image_default_align')),
   922 			'html'  => image_align_input_fields($post, get_option('image_default_align')),
   872 		);
   923 		);
   873 
   924 
   874 		$form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size'));
   925 		$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') );
       
   926 
       
   927 	} else {
       
   928 		unset( $form_fields['image_alt'] );
   875 	}
   929 	}
   876 	return $form_fields;
   930 	return $form_fields;
   877 }
   931 }
   878 
   932 
   879 add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
   933 add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
   931  */
   985  */
   932 function image_media_send_to_editor($html, $attachment_id, $attachment) {
   986 function image_media_send_to_editor($html, $attachment_id, $attachment) {
   933 	$post =& get_post($attachment_id);
   987 	$post =& get_post($attachment_id);
   934 	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
   988 	if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
   935 		$url = $attachment['url'];
   989 		$url = $attachment['url'];
   936 
   990 		$align = !empty($attachment['align']) ? $attachment['align'] : 'none';
   937 		if ( isset($attachment['align']) )
   991 		$size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium';
   938 			$align = $attachment['align'];
   992 		$alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : '';
   939 		else
       
   940 			$align = 'none';
       
   941 
       
   942 		if ( !empty($attachment['image-size']) )
       
   943 			$size = $attachment['image-size'];
       
   944 		else
       
   945 			$size = 'medium';
       
   946 
       
   947 		$rel = ( $url == get_attachment_link($attachment_id) );
   993 		$rel = ( $url == get_attachment_link($attachment_id) );
   948 
   994 
   949 		return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size);
   995 		return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt);
   950 	}
   996 	}
   951 
   997 
   952 	return $html;
   998 	return $html;
   953 }
   999 }
   954 
  1000 
   974 	$edit_post = sanitize_post($post, 'edit');
  1020 	$edit_post = sanitize_post($post, 'edit');
   975 
  1021 
   976 	$form_fields = array(
  1022 	$form_fields = array(
   977 		'post_title'   => array(
  1023 		'post_title'   => array(
   978 			'label'      => __('Title'),
  1024 			'label'      => __('Title'),
   979 			'value'      => $edit_post->post_title,
  1025 			'value'      => $edit_post->post_title
   980 		),
  1026 		),
       
  1027 		'image_alt'   => array(),
   981 		'post_excerpt' => array(
  1028 		'post_excerpt' => array(
   982 			'label'      => __('Caption'),
  1029 			'label'      => __('Caption'),
   983 			'value'      => $edit_post->post_excerpt,
  1030 			'value'      => $edit_post->post_excerpt
   984 		),
  1031 		),
   985 		'post_content' => array(
  1032 		'post_content' => array(
   986 			'label'      => __('Description'),
  1033 			'label'      => __('Description'),
   987 			'value'      => $edit_post->post_content,
  1034 			'value'      => $edit_post->post_content,
   988 			'input'      => 'textarea',
  1035 			'input'      => 'textarea'
   989 		),
  1036 		),
   990 		'url'          => array(
  1037 		'url'          => array(
   991 			'label'      => __('Link URL'),
  1038 			'label'      => __('Link URL'),
   992 			'input'      => 'html',
  1039 			'input'      => 'html',
   993 			'html'       => image_link_input_fields($post, get_option('image_default_link_type')),
  1040 			'html'       => image_link_input_fields($post, get_option('image_default_link_type')),
   994 			'helps'      => __('Enter a link URL or click above for presets.'),
  1041 			'helps'      => __('Enter a link URL or click above for presets.')
   995 		),
  1042 		),
   996 		'menu_order'   => array(
  1043 		'menu_order'   => array(
   997 			'label'      => __('Order'),
  1044 			'label'      => __('Order'),
   998 			'value'      => $edit_post->menu_order
  1045 			'value'      => $edit_post->menu_order
   999 		),
  1046 		),
  1000 		'image_url'	=> array(
  1047 		'image_url'	=> array(
  1001 			'label'      => __('File URL'),
  1048 			'label'      => __('File URL'),
  1002 			'input'      => 'html',
  1049 			'input'      => 'html',
  1003 			'html'       => "<input type='text' class='urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />",
  1050 			'html'       => "<input type='text' class='text urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />",
  1004 			'value'      => isset($edit_post->post_url) ? $edit_post->post_url : '',
  1051 			'value'      => wp_get_attachment_url($post->ID),
  1005 			'helps'      => __('Location of the uploaded file.'),
  1052 			'helps'      => __('Location of the uploaded file.')
  1006 		)
  1053 		)
  1007 	);
  1054 	);
  1008 
  1055 
  1009 	foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
  1056 	foreach ( get_attachment_taxonomies($post) as $taxonomy ) {
  1010 		$t = (array) get_taxonomy($taxonomy);
  1057 		$t = (array) get_taxonomy($taxonomy);
  1060 			foreach ( $GLOBALS['wp_the_query']->posts as $attachment )
  1107 			foreach ( $GLOBALS['wp_the_query']->posts as $attachment )
  1061 				$attachments[$attachment->ID] = $attachment;
  1108 				$attachments[$attachment->ID] = $attachment;
  1062 	}
  1109 	}
  1063 
  1110 
  1064 	$output = '';
  1111 	$output = '';
  1065 	foreach ( (array) $attachments as $id => $attachment )
  1112 	foreach ( (array) $attachments as $id => $attachment ) {
       
  1113 		if ( $attachment->post_status == 'trash' )
       
  1114 			continue;
  1066 		if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
  1115 		if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
  1067 			$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
  1116 			$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress'><div class='bar'></div></div><div id='media-upload-error-$id'></div><div class='filename'></div>$item\n</div>";
       
  1117 	}
  1068 
  1118 
  1069 	return $output;
  1119 	return $output;
  1070 }
  1120 }
  1071 
  1121 
  1072 /**
  1122 /**
  1079  * @return string HTML form for attachment.
  1129  * @return string HTML form for attachment.
  1080  */
  1130  */
  1081 function get_media_item( $attachment_id, $args = null ) {
  1131 function get_media_item( $attachment_id, $args = null ) {
  1082 	global $redir_tab;
  1132 	global $redir_tab;
  1083 
  1133 
  1084 	$default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true );
       
  1085 	$args = wp_parse_args( $args, $default_args );
       
  1086 	extract( $args, EXTR_SKIP );
       
  1087 
       
  1088 	global $post_mime_types;
       
  1089 	if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
  1134 	if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
  1090 		$thumb_url = $thumb_url[0];
  1135 		$thumb_url = $thumb_url[0];
  1091 	else
  1136 	else
  1092 		return false;
  1137 		return false;
  1093 
  1138 
       
  1139 	$default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true, 'show_title' => true );
       
  1140 	$args = wp_parse_args( $args, $default_args );
       
  1141 	extract( $args, EXTR_SKIP );
       
  1142 
  1094 	$toggle_on = __('Show');
  1143 	$toggle_on = __('Show');
  1095 	$toggle_off = __('Hide');
  1144 	$toggle_off = __('Hide');
  1096 
  1145 
  1097 	$post = get_post($attachment_id);
  1146 	$post = get_post($attachment_id);
  1098 
  1147 
  1103 		foreach ( $_tags as $tag )
  1152 		foreach ( $_tags as $tag )
  1104 			$tags[] = $tag->name;
  1153 			$tags[] = $tag->name;
  1105 		$tags = esc_attr(join(', ', $tags));
  1154 		$tags = esc_attr(join(', ', $tags));
  1106 	}
  1155 	}
  1107 
  1156 
  1108 	$type = '';
  1157 	$post_mime_types = get_post_mime_types();
  1109 	if ( isset($post_mime_types) ) {
  1158 	$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
  1110 		$keys = array_keys(wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));
  1159 	$type = array_shift($keys);
  1111 		$type = array_shift($keys);
  1160 	$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
  1112 		$type = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";
       
  1113 	}
       
  1114 
  1161 
  1115 	$form_fields = get_attachment_fields_to_edit($post, $errors);
  1162 	$form_fields = get_attachment_fields_to_edit($post, $errors);
  1116 
  1163 
  1117 	if ( $toggle ) {
  1164 	if ( $toggle ) {
  1118 		$class = empty($errors) ? 'startclosed' : 'startopen';
  1165 		$class = empty($errors) ? 'startclosed' : 'startopen';
  1123 		$class = 'form-table';
  1170 		$class = 'form-table';
  1124 		$toggle_links = '';
  1171 		$toggle_links = '';
  1125 	}
  1172 	}
  1126 
  1173 
  1127 	$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
  1174 	$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case
  1128 	$display_title = $show_title ? "<div class='filename new'>" . wp_html_excerpt($display_title, 60) . "</div>" : '';
  1175 	$display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt($display_title, 60) . "</span></div>" : '';
  1129 
  1176 
  1130 	$gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false;
  1177 	$gallery = ( (isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false;
  1131 	$order = '';
  1178 	$order = '';
  1132 
  1179 
  1133 	foreach ( $form_fields as $key => $val ) {
  1180 	foreach ( $form_fields as $key => $val ) {
  1140 			unset($form_fields['menu_order']);
  1187 			unset($form_fields['menu_order']);
  1141 			break;
  1188 			break;
  1142 		}
  1189 		}
  1143 	}
  1190 	}
  1144 
  1191 
       
  1192 	$media_dims = '';
       
  1193 	$meta = wp_get_attachment_metadata($post->ID);
       
  1194 	if ( is_array($meta) && array_key_exists('width', $meta) && array_key_exists('height', $meta) )
       
  1195 		$media_dims .= "<span id='media-dims-{$post->ID}'>{$meta['width']}&nbsp;&times;&nbsp;{$meta['height']}</span> ";
       
  1196 	$media_dims = apply_filters('media_meta', $media_dims, $post);
       
  1197 
       
  1198 	$image_edit_button = '';
       
  1199 	if ( gd_edit_image_support($post->post_mime_type) ) {
       
  1200 		$nonce = wp_create_nonce("image_editor-$post->ID");
       
  1201 		$image_edit_button = "<input type='button' id='imgedit-open-btn-{$post->ID}' onclick='imageEdit.open($post->ID, \"$nonce\")' class='button' value='" . esc_attr__( 'Edit image' ) . "' /> <img src='images/wpspin_light.gif' class='imgedit-wait-spin' alt='' />";
       
  1202 	}
       
  1203 
  1145 	$item = "
  1204 	$item = "
  1146 	$type
  1205 	$type_html
  1147 	$toggle_links
  1206 	$toggle_links
  1148 	$order
  1207 	$order
  1149 	$display_title
  1208 	$display_title
  1150 	<table class='slidetoggle describe $class'>
  1209 	<table class='slidetoggle describe $class'>
  1151 		<thead class='media-item-info'>
  1210 		<thead class='media-item-info' id='media-head-$post->ID'>
  1152 		<tr>
  1211 		<tr>
  1153 			<td class='A1B1' rowspan='4'><img class='thumbnail' src='$thumb_url' alt='' /></td>
  1212 			<td class='A1B1' id='thumbnail-head-$post->ID' rowspan='5'><img class='thumbnail' src='$thumb_url' alt='' /></td>
  1154 			<td>$filename</td>
  1213 			<td><strong>" . __('File name:') . "</strong> $filename</td>
  1155 		</tr>
  1214 		</tr>
  1156 		<tr><td>$post->post_mime_type</td></tr>
  1215 		<tr><td><strong>" . __('File type:') . "</strong> $post->post_mime_type</td></tr>
  1157 		<tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>
  1216 		<tr><td><strong>" . __('Upload date:') . "</strong> " . mysql2date( get_option('date_format'), $post->post_date ) . "</td></tr>\n";
  1158 		<tr><td>" . apply_filters('media_meta', '', $post) . "</td></tr>
  1217 
       
  1218 	if ( !empty($media_dims) )
       
  1219 		$item .= "<tr><td><strong>" . __('Dimensions:') . "</strong> $media_dims</td></tr>\n";
       
  1220 
       
  1221 	$item .= "
       
  1222 		<tr><td class='A1B1'>$image_edit_button</td></tr>
  1159 		</thead>
  1223 		</thead>
  1160 		<tbody>\n";
  1224 		<tbody>
       
  1225 		<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr>
       
  1226 		<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n";
  1161 
  1227 
  1162 	$defaults = array(
  1228 	$defaults = array(
  1163 		'input'      => 'text',
  1229 		'input'      => 'text',
  1164 		'required'   => false,
  1230 		'required'   => false,
  1165 		'value'      => '',
  1231 		'value'      => '',
  1166 		'extra_rows' => array(),
  1232 		'extra_rows' => array(),
  1167 	);
  1233 	);
  1168 
  1234 
  1169 	$delete_href = wp_nonce_url("post.php?action=delete-post&amp;post=$attachment_id", 'delete-post_' . $attachment_id);
       
  1170 	if ( $send )
  1235 	if ( $send )
  1171 		$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
  1236 		$send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />";
  1172 	if ( $delete )
  1237 	if ( $delete && current_user_can('delete_post', $attachment_id) ) {
  1173 		$delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a>";
  1238 		if ( !EMPTY_TRASH_DAYS ) {
  1174 	if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
  1239 			$delete = "<a href=\"" . wp_nonce_url("post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Delete Permanently') . "</a>";
  1175 		$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete
  1240 		} elseif ( !MEDIA_TRASH ) {
  1176 		<div id=\"del_attachment_$attachment_id\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"$delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Continue') . "</a>
  1241 			$delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a> <div id=\"del_attachment_$attachment_id\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"" . wp_nonce_url("post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"button\">" . __('Continue') . "</a> <a href=\"#\" class=\"button\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div>";
  1177 		<a href=\"#\" class=\"del-link\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div></td></tr>\n");
  1242 		} else {
       
  1243 			$delete = "<a href=\"" . wp_nonce_url("post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a> <a href=\"" . wp_nonce_url("post.php?action=untrash&amp;post=$attachment_id", 'untrash-post_' . $attachment_id) . "\" id=\"undo[$attachment_id]\" class=\"undo hidden\">" . __('Undo') . "</a>";
       
  1244 		}
       
  1245 	} else {
       
  1246 		$delete = '';
       
  1247 	}
       
  1248 
       
  1249 	$thumbnail = '';
       
  1250 	$calling_post_id = 0;
       
  1251 	if ( isset( $_GET['post_id'] ) )
       
  1252 		$calling_post_id = $_GET['post_id'];
       
  1253 	elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set
       
  1254 		$calling_post_id = $post->post_parent;
       
  1255 	if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id )
       
  1256 		$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>";
       
  1257 
       
  1258 	if ( ( $send || $thumbnail || $delete ) && !isset($form_fields['buttons']) )
       
  1259 		$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n");
  1178 
  1260 
  1179 	$hidden_fields = array();
  1261 	$hidden_fields = array();
  1180 
  1262 
  1181 	foreach ( $form_fields as $id => $field ) {
  1263 	foreach ( $form_fields as $id => $field ) {
  1182 		if ( $id{0} == '_' )
  1264 		if ( $id{0} == '_' )
  1204 		if ( !empty($field[$field['input']]) )
  1286 		if ( !empty($field[$field['input']]) )
  1205 			$item .= $field[$field['input']];
  1287 			$item .= $field[$field['input']];
  1206 		elseif ( $field['input'] == 'textarea' ) {
  1288 		elseif ( $field['input'] == 'textarea' ) {
  1207 			$item .= "<textarea type='text' id='$name' name='$name'" . $aria_required . ">" . esc_html( $field['value'] ) . "</textarea>";
  1289 			$item .= "<textarea type='text' id='$name' name='$name'" . $aria_required . ">" . esc_html( $field['value'] ) . "</textarea>";
  1208 		} else {
  1290 		} else {
  1209 			$item .= "<input type='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'" . $aria_required . "/>";
  1291 			$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "'" . $aria_required . "/>";
  1210 		}
  1292 		}
  1211 		if ( !empty($field['helps']) )
  1293 		if ( !empty($field['helps']) )
  1212 			$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique((array) $field['helps']) ) . '</p>';
  1294 			$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique((array) $field['helps']) ) . '</p>';
  1213 		$item .= "</td>\n\t\t</tr>\n";
  1295 		$item .= "</td>\n\t\t</tr>\n";
  1214 
  1296 
  1322 			file_post_name: "async-upload",
  1404 			file_post_name: "async-upload",
  1323 			file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
  1405 			file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
  1324 			post_params : {
  1406 			post_params : {
  1325 				"post_id" : "<?php echo $post_id; ?>",
  1407 				"post_id" : "<?php echo $post_id; ?>",
  1326 				"auth_cookie" : "<?php if ( is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>",
  1408 				"auth_cookie" : "<?php if ( is_ssl() ) echo $_COOKIE[SECURE_AUTH_COOKIE]; else echo $_COOKIE[AUTH_COOKIE]; ?>",
       
  1409 				"logged_in_cookie": "<?php echo $_COOKIE[LOGGED_IN_COOKIE]; ?>",
  1327 				"_wpnonce" : "<?php echo wp_create_nonce('media-form'); ?>",
  1410 				"_wpnonce" : "<?php echo wp_create_nonce('media-form'); ?>",
  1328 				"type" : "<?php echo $type; ?>",
  1411 				"type" : "<?php echo $type; ?>",
  1329 				"tab" : "<?php echo $tab; ?>",
  1412 				"tab" : "<?php echo $tab; ?>",
  1330 				"short" : "1"
  1413 				"short" : "1"
  1331 			},
  1414 			},
  1367 
  1450 
  1368 <div id="html-upload-ui">
  1451 <div id="html-upload-ui">
  1369 <?php do_action('pre-html-upload-ui'); ?>
  1452 <?php do_action('pre-html-upload-ui'); ?>
  1370 	<p id="async-upload-wrap">
  1453 	<p id="async-upload-wrap">
  1371 	<label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label>
  1454 	<label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label>
  1372 	<input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php esc_attr_e('Upload'); ?>" /> <a href="#" onclick="return top.tb_remove();"><?php _e('Cancel'); ?></a>
  1455 	<input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php esc_attr_e('Upload'); ?>" /> <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?></a>
  1373 	</p>
  1456 	</p>
  1374 	<div class="clear"></div>
  1457 	<div class="clear"></div>
  1375 	<?php if ( is_lighttpd_before_150() ): ?>
  1458 	<?php if ( is_lighttpd_before_150() ): ?>
  1376 	<p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p>
  1459 	<p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p>
  1377 	<?php endif;?>
  1460 	<?php endif;?>
  1398 	$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
  1481 	$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
  1399 	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
  1482 	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
  1400 ?>
  1483 ?>
  1401 
  1484 
  1402 <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">
  1485 <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">
       
  1486 <input type="submit" class="hidden" name="save" value="" />
  1403 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
  1487 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
  1404 <?php wp_nonce_field('media-form'); ?>
  1488 <?php wp_nonce_field('media-form'); ?>
  1405 
  1489 
  1406 <h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3>
  1490 <h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3>
  1407 
  1491 
  1472 	width : '',
  1556 	width : '',
  1473 	height : '',
  1557 	height : '',
  1474 	align : 'alignnone',
  1558 	align : 'alignnone',
  1475 
  1559 
  1476 	insert : function() {
  1560 	insert : function() {
  1477 		var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = null;
  1561 		var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = '';
  1478 
  1562 
  1479 		if ( '' == f.src.value || '' == t.width ) return false;
  1563 		if ( '' == f.src.value || '' == t.width )
       
  1564 			return false;
  1480 
  1565 
  1481 		if ( f.title.value ) {
  1566 		if ( f.title.value ) {
  1482 			title = f.title.value.replace(/['"<>]+/g, '');
  1567 			title = f.title.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  1483 			title = ' title="'+title+'"';
  1568 			title = ' title="'+title+'"';
  1484 		}
  1569 		}
  1485 
  1570 
  1486 		if ( f.alt.value ) {
  1571 		if ( f.alt.value )
  1487 			alt = f.alt.value.replace(/['"<>]+/g, '');
  1572 			alt = f.alt.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
       
  1573 
  1488 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
  1574 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?>
  1489 			caption = f.alt.value.replace(/'/g, '&#39;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  1575 		if ( f.caption.value )
       
  1576 			caption = f.caption.value.replace(/'/g, '&#039;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  1490 <?php } ?>
  1577 <?php } ?>
  1491 		}
       
  1492 
  1578 
  1493 		cls = caption ? '' : ' class="'+t.align+'"';
  1579 		cls = caption ? '' : ' class="'+t.align+'"';
  1494 
  1580 
  1495 		html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />';
  1581 		html = '<img alt="'+alt+'" src="'+f.src.value+'"'+title+cls+' width="'+t.width+'" height="'+t.height+'" />';
  1496 
  1582 
  1500 		if ( caption )
  1586 		if ( caption )
  1501 			html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]';
  1587 			html = '[caption id="" align="'+t.align+'" width="'+t.width+'" caption="'+caption+'"]'+html+'[/caption]';
  1502 
  1588 
  1503 		var win = window.dialogArguments || opener || parent || top;
  1589 		var win = window.dialogArguments || opener || parent || top;
  1504 		win.send_to_editor(html);
  1590 		win.send_to_editor(html);
       
  1591 		return false;
  1505 	},
  1592 	},
  1506 
  1593 
  1507 	resetImageData : function() {
  1594 	resetImageData : function() {
  1508 		var t = addExtImage;
  1595 		var t = addExtImage;
  1509 
  1596 
  1510 		t.width = t.height = '';
  1597 		t.width = t.height = '';
  1511 		document.getElementById('go_button').style.color = '#bbb';
  1598 		document.getElementById('go_button').style.color = '#bbb';
  1512 		if ( ! document.forms[0].src.value )
  1599 		if ( ! document.forms[0].src.value )
  1513 			document.getElementById('status_img').src = 'images/required.gif';
  1600 			document.getElementById('status_img').innerHTML = '*';
  1514 		else document.getElementById('status_img').src = 'images/no.png';
  1601 		else document.getElementById('status_img').innerHTML = '<img src="images/no.png" alt="" />';
  1515 	},
  1602 	},
  1516 
  1603 
  1517 	updateImageData : function() {
  1604 	updateImageData : function() {
  1518 		var t = addExtImage;
  1605 		var t = addExtImage;
  1519 
  1606 
  1520 		t.width = t.preloadImg.width;
  1607 		t.width = t.preloadImg.width;
  1521 		t.height = t.preloadImg.height;
  1608 		t.height = t.preloadImg.height;
  1522 		document.getElementById('go_button').style.color = '#333';
  1609 		document.getElementById('go_button').style.color = '#333';
  1523 		document.getElementById('status_img').src = 'images/yes.png';
  1610 		document.getElementById('status_img').innerHTML = '<img src="images/yes.png" alt="" />';
  1524 	},
  1611 	},
  1525 
  1612 
  1526 	getImageData : function() {
  1613 	getImageData : function() {
  1527 		var t = addExtImage, src = document.forms[0].src.value;
  1614 		var t = addExtImage, src = document.forms[0].src.value;
  1528 
  1615 
  1529 		if ( ! src ) {
  1616 		if ( ! src ) {
  1530 			t.resetImageData();
  1617 			t.resetImageData();
  1531 			return false;
  1618 			return false;
  1532 		}
  1619 		}
  1533 		document.getElementById('status_img').src = 'images/wpspin_light.gif';
  1620 		document.getElementById('status_img').innerHTML = '<img src="images/wpspin_light.gif" alt="" />';
  1534 		t.preloadImg = new Image();
  1621 		t.preloadImg = new Image();
  1535 		t.preloadImg.onload = t.updateImageData;
  1622 		t.preloadImg.onload = t.updateImageData;
  1536 		t.preloadImg.onerror = t.resetImageData;
  1623 		t.preloadImg.onerror = t.resetImageData;
  1537 		t.preloadImg.src = src;
  1624 		t.preloadImg.src = src;
  1538 	}
  1625 	}
  1558  * @since unknown
  1645  * @since unknown
  1559  *
  1646  *
  1560  * @param unknown_type $errors
  1647  * @param unknown_type $errors
  1561  */
  1648  */
  1562 function media_upload_gallery_form($errors) {
  1649 function media_upload_gallery_form($errors) {
  1563 	global $redir_tab;
  1650 	global $redir_tab, $type;
  1564 
  1651 
  1565 	$redir_tab = 'gallery';
  1652 	$redir_tab = 'gallery';
  1566 	media_upload_header();
  1653 	media_upload_header();
  1567 
  1654 
  1568 	$post_id = intval($_REQUEST['post_id']);
  1655 	$post_id = intval($_REQUEST['post_id']);
  1569 	$form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=gallery&post_id=$post_id");
  1656 	$form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id");
       
  1657 	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
  1570 ?>
  1658 ?>
  1571 
  1659 
  1572 <script type="text/javascript">
  1660 <script type="text/javascript">
  1573 <!--
  1661 <!--
  1574 jQuery(function($){
  1662 jQuery(function($){
  1587 <a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a>
  1675 <a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a>
  1588 </span>
  1676 </span>
  1589 <?php _e('Sort Order:'); ?>
  1677 <?php _e('Sort Order:'); ?>
  1590 <a href="#" id="asc"><?php _e('Ascending'); ?></a> |
  1678 <a href="#" id="asc"><?php _e('Ascending'); ?></a> |
  1591 <a href="#" id="desc"><?php _e('Descending'); ?></a> |
  1679 <a href="#" id="desc"><?php _e('Descending'); ?></a> |
  1592 <a href="#" id="clear"><?php _e('Clear'); ?></a>
  1680 <a href="#" id="clear"><?php echo _x('Clear', 'verb'); ?></a>
  1593 </div>
  1681 </div>
  1594 <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
  1682 <form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
  1595 <?php wp_nonce_field('media-form'); ?>
  1683 <?php wp_nonce_field('media-form'); ?>
  1596 <?php //media_upload_form( $errors ); ?>
  1684 <?php //media_upload_form( $errors ); ?>
  1597 <table class="widefat" cellspacing="0">
  1685 <table class="widefat" cellspacing="0">
  1598 <thead><tr>
  1686 <thead><tr>
  1599 <th><?php _e('Media'); ?></th>
  1687 <th><?php _e('Media'); ?></th>
  1600 <th class="order-head"><?php _e('Order'); ?></th>
  1688 <th class="order-head"><?php _e('Order'); ?></th>
       
  1689 <th class="actions-head"><?php _e('Actions'); ?></th>
  1601 </tr></thead>
  1690 </tr></thead>
  1602 </table>
  1691 </table>
  1603 <div id="media-items">
  1692 <div id="media-items">
  1604 <?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
  1693 <?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?>
  1605 <?php echo get_media_items($post_id, $errors); ?>
  1694 <?php echo get_media_items($post_id, $errors); ?>
  1703 
  1792 
  1704 	media_upload_header();
  1793 	media_upload_header();
  1705 
  1794 
  1706 	$post_id = intval($_REQUEST['post_id']);
  1795 	$post_id = intval($_REQUEST['post_id']);
  1707 
  1796 
  1708 	$form_action_url = admin_url("media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id");
  1797 	$form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id");
       
  1798 	$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
  1709 
  1799 
  1710 	$_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
  1800 	$_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0;
  1711 	if ( $_GET['paged'] < 1 )
  1801 	if ( $_GET['paged'] < 1 )
  1712 		$_GET['paged'] = 1;
  1802 		$_GET['paged'] = 1;
  1713 	$start = ( $_GET['paged'] - 1 ) * 10;
  1803 	$start = ( $_GET['paged'] - 1 ) * 10;
  1800 foreach ($arc_result as $arc_row) {
  1890 foreach ($arc_result as $arc_row) {
  1801 	if ( $arc_row->yyear == 0 )
  1891 	if ( $arc_row->yyear == 0 )
  1802 		continue;
  1892 		continue;
  1803 	$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
  1893 	$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 );
  1804 
  1894 
  1805 	if ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] )
  1895 	if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) )
  1806 		$default = ' selected="selected"';
  1896 		$default = ' selected="selected"';
  1807 	else
  1897 	else
  1808 		$default = '';
  1898 		$default = '';
  1809 
  1899 
  1810 	echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
  1900 	echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>";
  1859  *
  1949  *
  1860  * @return unknown
  1950  * @return unknown
  1861  */
  1951  */
  1862 function type_url_form_image() {
  1952 function type_url_form_image() {
  1863 
  1953 
  1864 	if ( apply_filters( 'disable_captions', '' ) ) {
  1954 	if ( !apply_filters( 'disable_captions', '' ) ) {
  1865 		$alt = __('Alternate Text');
  1955 		$caption = '
  1866 		$alt_help = __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;');
  1956 		<tr>
       
  1957 			<th valign="top" scope="row" class="label">
       
  1958 				<span class="alignleft"><label for="caption">' . __('Image Caption') . '</label></span>
       
  1959 			</th>
       
  1960 			<td class="field"><input id="caption" name="caption" value="" type="text" /></td>
       
  1961 		</tr>
       
  1962 ';
  1867 	} else {
  1963 	} else {
  1868 		$alt = __('Image Caption');
  1964 		$caption = '';
  1869 		$alt_help = __('Also used as alternate text for the image');
       
  1870 	}
  1965 	}
  1871 
  1966 
  1872 	$default_align = get_option('image_default_align');
  1967 	$default_align = get_option('image_default_align');
  1873 	if ( empty($default_align) )
  1968 	if ( empty($default_align) )
  1874 		$default_align = 'none';
  1969 		$default_align = 'none';
  1875 
  1970 
  1876 	return '
  1971 	return '
       
  1972 	<h4 class="media-sub-title">' . __('Insert an image from another web site') . '</h4>
  1877 	<table class="describe"><tbody>
  1973 	<table class="describe"><tbody>
  1878 		<tr>
  1974 		<tr>
  1879 			<th valign="top" scope="row" class="label" style="width:120px;">
  1975 			<th valign="top" scope="row" class="label" style="width:130px;">
  1880 				<span class="alignleft"><label for="src">' . __('Image URL') . '</label></span>
  1976 				<span class="alignleft"><label for="src">' . __('Image URL') . '</label></span>
  1881 				<span class="alignright"><img id="status_img" src="images/required.gif" title="required" alt="required" /></span>
  1977 				<span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span>
  1882 			</th>
  1978 			</th>
  1883 			<td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td>
  1979 			<td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td>
  1884 		</tr>
  1980 		</tr>
  1885 
  1981 
  1886 		<tr>
  1982 		<tr>
  1887 			<th valign="top" scope="row" class="label">
  1983 			<th valign="top" scope="row" class="label">
  1888 				<span class="alignleft"><label for="title">' . __('Image Title') . '</label></span>
  1984 				<span class="alignleft"><label for="title">' . __('Image Title') . '</label></span>
  1889 				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
  1985 				<span class="alignright"><abbr title="required" class="required">*</abbr></span>
  1890 			</th>
  1986 			</th>
  1891 			<td class="field"><p><input id="title" name="title" value="" type="text" aria-required="true" /></p></td>
  1987 			<td class="field"><input id="title" name="title" value="" type="text" aria-required="true" /></td>
  1892 		</tr>
  1988 		</tr>
  1893 
  1989 
  1894 		<tr>
  1990 		<tr>
  1895 			<th valign="top" scope="row" class="label">
  1991 			<th valign="top" scope="row" class="label">
  1896 				<span class="alignleft"><label for="alt">' . $alt . '</label></span>
  1992 				<span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span>
  1897 			</th>
  1993 			</th>
  1898 			<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
  1994 			<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" />
  1899 			<p class="help">' . $alt_help . '</p></td>
  1995 			<p class="help">' . __('Alt text for the image, e.g. &#8220;The Mona Lisa&#8221;') . '</p></td>
  1900 		</tr>
  1996 		</tr>
  1901 
  1997 		' . $caption . '
  1902 		<tr class="align">
  1998 		<tr class="align">
  1903 			<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
  1999 			<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th>
  1904 			<td class="field">
  2000 			<td class="field">
  1905 				<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
  2001 				<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' />
  1906 				<label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
  2002 				<label for="align-none" class="align image-align-none-label">' . __('None') . '</label>
  2118 
  2214 
  2119 add_filter('media_upload_gallery', 'media_upload_gallery');
  2215 add_filter('media_upload_gallery', 'media_upload_gallery');
  2120 
  2216 
  2121 add_filter('media_upload_library', 'media_upload_library');
  2217 add_filter('media_upload_library', 'media_upload_library');
  2122 
  2218 
  2123 ?>