Changeset 18831
- Timestamp:
- 09/30/2011 06:22:29 AM (14 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
-
css/media.dev.css (modified) (1 diff)
-
includes/media.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/media.dev.css
r18802 r18831 363 363 } 364 364 365 p.media-types { 366 margin: 1em; 367 } 368 369 tr.not-image { 370 display: none; 371 } 372 373 table.not-image tr.not-image { 374 display: table-row; 375 } 376 377 table.not-image tr.image-only { 378 display: none; 379 } -
trunk/wp-admin/includes/media.php
r18823 r18831 375 375 */ 376 376 function media_buttons($editor_id = 'content') { 377 $out = ''; 378 379 if ( is_multisite() ) 380 $_buttons = get_site_option('mu_media_buttons'); 381 else 382 $_buttons = array( 'image' => true, 'video' => true, 'audio' => true ); 383 384 if ( !empty($_buttons['image']) ) 385 $out .= _media_button(__('Add an Image'), 'images/media-button-image.gif?ver=20100531', 'image', $editor_id); 386 if ( !empty($_buttons['video']) ) 387 $out .= _media_button(__('Add Video'), 'images/media-button-video.gif?ver=20100531', 'video', $editor_id); 388 if ( !empty($_buttons['audio']) ) 389 $out .= _media_button(__('Add Audio'), 'images/media-button-music.gif?ver=20100531', 'audio', $editor_id); 390 391 $out .= _media_button(__('Add Media'), 'images/media-button-other.gif?ver=20100531', 'media', $editor_id); 377 $out = _media_button(__('Add Media'), 'images/media-button-video.gif?ver=20100531', 'media', $editor_id); 392 378 393 379 $context = apply_filters('media_buttons_context', __('Upload/Insert %s')); … … 530 516 531 517 if ( !empty($_POST['insertonlybutton']) ) { 532 $alt = $align = '';533 534 518 $src = $_POST['insertonly']['src']; 535 519 if ( !empty($src) && !strpos($src, '://') ) 536 520 $src = "http://$src"; 537 $alt = esc_attr($_POST['insertonly']['alt']); 538 if ( isset($_POST['insertonly']['align']) ) { 539 $align = esc_attr($_POST['insertonly']['align']); 540 $class = " class='align$align'"; 521 522 if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) { 523 $title = esc_attr($_POST['insertonly']['title']); 524 if ( empty($title) ) 525 $title = esc_attr( basename($src) ); 526 527 if ( !empty($title) && !empty($src) ) 528 $html = "<a href='" . esc_url($src) . "' >$title</a>"; 529 530 $type = 'file'; 531 if ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) && $ext_type = wp_ext2type( $ext ) 532 && ( 'audio' == $ext_type || 'video' == $ext_type ) ) 533 $type = $ext_type; 534 535 $html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title ); 536 } else { 537 $align = ''; 538 $alt = esc_attr($_POST['insertonly']['alt']); 539 if ( isset($_POST['insertonly']['align']) ) { 540 $align = esc_attr($_POST['insertonly']['align']); 541 $class = " class='align$align'"; 542 } 543 if ( !empty($src) ) 544 $html = "<img src='" . esc_url($src) . "' alt='$alt'$class />"; 545 546 $html = apply_filters( 'image_send_to_editor_url', $html, esc_url_raw( $src ), $alt, $align ); 541 547 } 542 if ( !empty($src) ) 543 $html = "<img src='" . esc_url($src) . "' alt='$alt'$class />"; 544 545 $html = apply_filters('image_send_to_editor_url', $html, esc_url_raw($src), $alt, $align); 548 546 549 return media_send_to_editor($html); 547 550 } … … 561 564 } 562 565 563 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) 564 return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id ); 566 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) { 567 $type = 'image'; 568 if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) ) 569 $type = $_GET['type']; 570 return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id ); 571 } 565 572 566 573 return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); … … 611 618 return $html; 612 619 } 613 }614 615 /**616 * {@internal Missing Short Description}}617 *618 * @since 2.5.0619 *620 * @return unknown621 */622 function media_upload_audio() {623 $errors = array();624 $id = 0;625 626 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {627 check_admin_referer('media-form');628 // Upload File button was clicked629 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);630 unset($_FILES);631 if ( is_wp_error($id) ) {632 $errors['upload_error'] = $id;633 $id = false;634 }635 }636 637 if ( !empty($_POST['insertonlybutton']) ) {638 $href = $_POST['insertonly']['href'];639 if ( !empty($href) && !strpos($href, '://') )640 $href = "http://$href";641 642 $title = esc_attr($_POST['insertonly']['title']);643 if ( empty($title) )644 $title = esc_attr( basename($href) );645 646 if ( !empty($title) && !empty($href) )647 $html = "<a href='" . esc_url($href) . "' >$title</a>";648 649 $html = apply_filters('audio_send_to_editor_url', $html, $href, $title);650 651 return media_send_to_editor($html);652 }653 654 if ( !empty($_POST) ) {655 $return = media_upload_form_handler();656 657 if ( is_string($return) )658 return $return;659 if ( is_array($return) )660 $errors = $return;661 }662 663 if ( isset($_POST['save']) ) {664 $errors['upload_notice'] = __('Saved.');665 return media_upload_gallery();666 }667 668 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )669 return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id );670 671 return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id );672 }673 674 /**675 * {@internal Missing Short Description}}676 *677 * @since 2.5.0678 *679 * @return unknown680 */681 function media_upload_video() {682 $errors = array();683 $id = 0;684 685 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {686 check_admin_referer('media-form');687 // Upload File button was clicked688 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);689 unset($_FILES);690 if ( is_wp_error($id) ) {691 $errors['upload_error'] = $id;692 $id = false;693 }694 }695 696 if ( !empty($_POST['insertonlybutton']) ) {697 $href = $_POST['insertonly']['href'];698 if ( !empty($href) && !strpos($href, '://') )699 $href = "http://$href";700 701 $title = esc_attr($_POST['insertonly']['title']);702 if ( empty($title) )703 $title = esc_attr( basename($href) );704 705 if ( !empty($title) && !empty($href) )706 $html = "<a href='" . esc_url($href) . "' >$title</a>";707 708 $html = apply_filters('video_send_to_editor_url', $html, $href, $title);709 710 return media_send_to_editor($html);711 }712 713 if ( !empty($_POST) ) {714 $return = media_upload_form_handler();715 716 if ( is_string($return) )717 return $return;718 if ( is_array($return) )719 $errors = $return;720 }721 722 if ( isset($_POST['save']) ) {723 $errors['upload_notice'] = __('Saved.');724 return media_upload_gallery();725 }726 727 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )728 return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id );729 730 return wp_iframe( 'media_upload_type_form', 'video', $errors, $id );731 }732 733 /**734 * {@internal Missing Short Description}}735 *736 * @since 2.5.0737 *738 * @return unknown739 */740 function media_upload_file() {741 $errors = array();742 $id = 0;743 744 if ( isset($_POST['html-upload']) && !empty($_FILES) ) {745 check_admin_referer('media-form');746 // Upload File button was clicked747 $id = media_handle_upload('async-upload', $_REQUEST['post_id']);748 unset($_FILES);749 if ( is_wp_error($id) ) {750 $errors['upload_error'] = $id;751 $id = false;752 }753 }754 755 if ( !empty($_POST['insertonlybutton']) ) {756 $href = $_POST['insertonly']['href'];757 if ( !empty($href) && !strpos($href, '://') )758 $href = "http://$href";759 760 $title = esc_attr($_POST['insertonly']['title']);761 if ( empty($title) )762 $title = basename($href);763 if ( !empty($title) && !empty($href) )764 $html = "<a href='" . esc_url($href) . "' >$title</a>";765 $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);766 return media_send_to_editor($html);767 }768 769 if ( !empty($_POST) ) {770 $return = media_upload_form_handler();771 772 if ( is_string($return) )773 return $return;774 if ( is_array($return) )775 $errors = $return;776 }777 778 if ( isset($_POST['save']) ) {779 $errors['upload_notice'] = __('Saved.');780 return media_upload_gallery();781 }782 783 if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )784 return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id );785 786 return wp_iframe( 'media_upload_type_form', 'file', $errors, $id );787 620 } 788 621 … … 1608 1441 * @param unknown_type $id 1609 1442 */ 1610 function media_upload_type_url_form($type = 'file', $errors = null, $id = null) { 1443 function media_upload_type_url_form($type = null, $errors = null, $id = null) { 1444 if ( null === $type ) 1445 $type = 'image'; 1446 1611 1447 media_upload_header(); 1612 1448 … … 1615 1451 $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); 1616 1452 $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); 1617 1618 $callback = "type_url_form_$type";1619 1453 ?> 1620 1454 … … 1622 1456 <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> 1623 1457 <?php wp_nonce_field('media-form'); ?> 1624 1625 <?php if ( is_callable($callback) ) { ?>1626 1458 1627 1459 <h3 class="media-title"><?php _e('Add media file from URL'); ?></h3> … … 1691 1523 var t = addExtImage, src = document.forms[0].src.value; 1692 1524 1693 if ( ! src ) {1525 if ( ! src || jQuery('table.describe').hasClass('not-image') ) { 1694 1526 t.resetImageData(); 1695 1527 return false; 1696 1528 } 1529 1697 1530 document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />'; 1698 1531 t.preloadImg = new Image(); … … 1702 1535 } 1703 1536 } 1537 1538 jQuery(document).ready( function($) { 1539 $('.media-types input').click( function() { 1540 $('table.describe').toggleClass('not-image', $('#not-image').prop('checked') ); 1541 }); 1542 }); 1543 1704 1544 //]]> 1705 1545 </script> … … 1707 1547 <div id="media-items"> 1708 1548 <div class="media-item media-blank"> 1709 <?php echo apply_filters( $callback, call_user_func($callback)); ?>1549 <?php echo apply_filters( 'type_url_form_media', type_url_form_image( $type ) ); ?> 1710 1550 </div> 1711 1551 </div> 1712 1552 </form> 1713 1553 <?php 1714 } else {1715 wp_die( __('Unknown action.') );1716 }1717 1554 } 1718 1555 … … 2028 1865 * @return unknown 2029 1866 */ 2030 function type_url_form_image( ) {1867 function type_url_form_image( $default_view = 'image' ) { 2031 1868 if ( !apply_filters( 'disable_captions', '' ) ) { 2032 1869 $caption = ' 2033 <tr >1870 <tr class="image-only"> 2034 1871 <th valign="top" scope="row" class="label"> 2035 1872 <span class="alignleft"><label for="caption">' . __('Image Caption') . '</label></span> … … 2046 1883 $default_align = 'none'; 2047 1884 1885 if ( 'image' == $default_view ) { 1886 $view = 'image-only'; 1887 $table_class = ''; 1888 } else { 1889 $view = $table_class = 'not-image'; 1890 } 1891 2048 1892 return ' 2049 <h4 class="media-sub-title">' . __('Insert an image from another web site') . '</h4> 2050 <table class="describe"><tbody> 1893 <h4 class="media-sub-title">' . __('Insert media from another web site') . '</h4> 1894 <p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Images' ) . '</label> <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Files' ) . '</label></p> 1895 <table class="describe ' . $table_class . '"><tbody> 2051 1896 <tr> 2052 1897 <th valign="top" scope="row" class="label" style="width:130px;"> 2053 <span class="alignleft"><label for="src">' . __(' ImageURL') . '</label></span>1898 <span class="alignleft"><label for="src">' . __('URL') . '</label></span> 2054 1899 <span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span> 2055 1900 </th> … … 2059 1904 <tr> 2060 1905 <th valign="top" scope="row" class="label"> 2061 <span class="alignleft"><label for="title">' . __(' ImageTitle') . '</label></span>1906 <span class="alignleft"><label for="title">' . __('Title') . '</label></span> 2062 1907 <span class="alignright"><abbr title="required" class="required">*</abbr></span> 2063 1908 </th> … … 2065 1910 </tr> 2066 1911 2067 <tr> 1912 <tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</p></td></tr> 1913 1914 <tr class="image-only"> 2068 1915 <th valign="top" scope="row" class="label"> 2069 1916 <span class="alignleft"><label for="alt">' . __('Alternate Text') . '</label></span> … … 2073 1920 </tr> 2074 1921 ' . $caption . ' 2075 <tr class="align ">1922 <tr class="align image-only"> 2076 1923 <th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th> 2077 1924 <td class="field"> … … 2087 1934 </tr> 2088 1935 2089 <tr >1936 <tr class="image-only"> 2090 1937 <th valign="top" scope="row" class="label"> 2091 1938 <span class="alignleft"><label for="url">' . __('Link Image To:') . '</label></span> … … 2097 1944 <p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td> 2098 1945 </tr> 2099 ' . _insert_into_post_button('image') . ' 1946 <tr class="image-only"> 1947 <td></td> 1948 <td> 1949 <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" /> 1950 </td> 1951 </tr> 1952 <tr class="not-image"> 1953 <td></td> 1954 <td> 1955 ' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . ' 1956 </td> 1957 </tr> 2100 1958 </tbody></table> 2101 1959 '; 2102 1960 2103 1961 } 2104 2105 /**2106 * {@internal Missing Short Description}}2107 *2108 * @since 2.7.02109 *2110 * @return unknown2111 */2112 function type_url_form_audio() {2113 return '2114 <table class="describe"><tbody>2115 <tr>2116 <th valign="top" scope="row" class="label">2117 <span class="alignleft"><label for="insertonly[href]">' . __('Audio File URL') . '</label></span>2118 <span class="alignright"><abbr title="required" class="required">*</abbr></span>2119 </th>2120 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>2121 </tr>2122 <tr>2123 <th valign="top" scope="row" class="label">2124 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>2125 <span class="alignright"><abbr title="required" class="required">*</abbr></span>2126 </th>2127 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>2128 </tr>2129 <tr><td></td><td class="help">' . __('Link text, e.g. “Still Alive by Jonathan Coulton”') . '</td></tr>2130 ' . _insert_into_post_button('audio') . '2131 </tbody></table>2132 ';2133 }2134 2135 /**2136 * {@internal Missing Short Description}}2137 *2138 * @since 2.7.02139 *2140 * @return unknown2141 */2142 function type_url_form_video() {2143 return '2144 <table class="describe"><tbody>2145 <tr>2146 <th valign="top" scope="row" class="label">2147 <span class="alignleft"><label for="insertonly[href]">' . __('Video URL') . '</label></span>2148 <span class="alignright"><abbr title="required" class="required">*</abbr></span>2149 </th>2150 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>2151 </tr>2152 <tr>2153 <th valign="top" scope="row" class="label">2154 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>2155 <span class="alignright"><abbr title="required" class="required">*</abbr></span>2156 </th>2157 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>2158 </tr>2159 <tr><td></td><td class="help">' . __('Link text, e.g. “Lucy on YouTube”') . '</td></tr>2160 ' . _insert_into_post_button('video') . '2161 </tbody></table>2162 ';2163 }2164 2165 /**2166 * {@internal Missing Short Description}}2167 *2168 * @since 2.7.02169 *2170 * @return unknown2171 */2172 function type_url_form_file() {2173 return '2174 <table class="describe"><tbody>2175 <tr>2176 <th valign="top" scope="row" class="label">2177 <span class="alignleft"><label for="insertonly[href]">' . __('URL') . '</label></span>2178 <span class="alignright"><abbr title="required" class="required">*</abbr></span>2179 </th>2180 <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true"></td>2181 </tr>2182 <tr>2183 <th valign="top" scope="row" class="label">2184 <span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>2185 <span class="alignright"><abbr title="required" class="required">*</abbr></span>2186 </th>2187 <td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text" aria-required="true"></td>2188 </tr>2189 <tr><td></td><td class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</td></tr>2190 ' . _insert_into_post_button('file') . '2191 </tbody></table>2192 ';2193 }2194 2195 1962 2196 1963 function _insert_into_post_button($type) { … … 2241 2008 2242 2009 add_action('media_upload_image', 'media_upload_image'); 2243 add_action('media_upload_audio', 'media_upload_ audio');2244 add_action('media_upload_video', 'media_upload_ video');2245 add_action('media_upload_file', 'media_upload_ file');2010 add_action('media_upload_audio', 'media_upload_image'); 2011 add_action('media_upload_video', 'media_upload_image'); 2012 add_action('media_upload_file', 'media_upload_image'); 2246 2013 2247 2014 add_filter('media_upload_gallery', 'media_upload_gallery');
Note: See TracChangeset
for help on using the changeset viewer.