options-media.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /**
  3. * Media settings administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once( dirname( __FILE__ ) . '/admin.php' );
  10. if ( ! current_user_can( 'manage_options' ) )
  11. wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
  12. $title = __('Media Settings');
  13. $parent_file = 'options-general.php';
  14. $media_options_help = '<p>' . __('You can set maximum sizes for images inserted into your written content; you can also insert an image as Full Size.') . '</p>';
  15. if ( ! is_multisite() && ( get_option('upload_url_path') || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) ) {
  16. $media_options_help .= '<p>' . __('Uploading Files allows you to choose the folder and path for storing your uploaded files.') . '</p>';
  17. }
  18. $media_options_help .= '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>';
  19. get_current_screen()->add_help_tab( array(
  20. 'id' => 'overview',
  21. 'title' => __('Overview'),
  22. 'content' => $media_options_help,
  23. ) );
  24. get_current_screen()->set_help_sidebar(
  25. '<p><strong>' . __('For more information:') . '</strong></p>' .
  26. '<p>' . __('<a href="https://codex.wordpress.org/Settings_Media_Screen">Documentation on Media Settings</a>') . '</p>' .
  27. '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
  28. );
  29. include( ABSPATH . 'wp-admin/admin-header.php' );
  30. ?>
  31. <div class="wrap">
  32. <h1><?php echo esc_html( $title ); ?></h1>
  33. <form action="options.php" method="post">
  34. <?php settings_fields('media'); ?>
  35. <h2 class="title"><?php _e('Image sizes') ?></h2>
  36. <p><?php _e( 'The sizes listed below determine the maximum dimensions in pixels to use when adding an image to the Media Library.' ); ?></p>
  37. <table class="form-table">
  38. <tr>
  39. <th scope="row"><?php _e('Thumbnail size') ?></th>
  40. <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Thumbnail size' ); ?></span></legend>
  41. <label for="thumbnail_size_w"><?php _e( 'Width' ); ?></label>
  42. <input name="thumbnail_size_w" type="number" step="1" min="0" id="thumbnail_size_w" value="<?php form_option( 'thumbnail_size_w' ); ?>" class="small-text" />
  43. <br />
  44. <label for="thumbnail_size_h"><?php _e( 'Height' ); ?></label>
  45. <input name="thumbnail_size_h" type="number" step="1" min="0" id="thumbnail_size_h" value="<?php form_option( 'thumbnail_size_h' ); ?>" class="small-text" />
  46. </fieldset>
  47. <input name="thumbnail_crop" type="checkbox" id="thumbnail_crop" value="1" <?php checked( '1', get_option( 'thumbnail_crop' ) ); ?>/>
  48. <label for="thumbnail_crop"><?php _e( 'Crop thumbnail to exact dimensions (normally thumbnails are proportional)' ); ?></label>
  49. </td>
  50. </tr>
  51. <tr>
  52. <th scope="row"><?php _e('Medium size') ?></th>
  53. <td><fieldset><legend class="screen-reader-text"><span><?php _e('Medium size'); ?></span></legend>
  54. <label for="medium_size_w"><?php _e('Max Width'); ?></label>
  55. <input name="medium_size_w" type="number" step="1" min="0" id="medium_size_w" value="<?php form_option('medium_size_w'); ?>" class="small-text" />
  56. <br />
  57. <label for="medium_size_h"><?php _e('Max Height'); ?></label>
  58. <input name="medium_size_h" type="number" step="1" min="0" id="medium_size_h" value="<?php form_option('medium_size_h'); ?>" class="small-text" />
  59. </fieldset></td>
  60. </tr>
  61. <tr>
  62. <th scope="row"><?php _e('Large size') ?></th>
  63. <td><fieldset><legend class="screen-reader-text"><span><?php _e('Large size'); ?></span></legend>
  64. <label for="large_size_w"><?php _e('Max Width'); ?></label>
  65. <input name="large_size_w" type="number" step="1" min="0" id="large_size_w" value="<?php form_option('large_size_w'); ?>" class="small-text" />
  66. <br />
  67. <label for="large_size_h"><?php _e('Max Height'); ?></label>
  68. <input name="large_size_h" type="number" step="1" min="0" id="large_size_h" value="<?php form_option('large_size_h'); ?>" class="small-text" />
  69. </fieldset></td>
  70. </tr>
  71. <?php do_settings_fields('media', 'default'); ?>
  72. </table>
  73. <?php
  74. /**
  75. * @global array $wp_settings
  76. */
  77. if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : ?>
  78. <h2 class="title"><?php _e('Embeds') ?></h2>
  79. <table class="form-table">
  80. <?php do_settings_fields( 'media', 'embeds' ); ?>
  81. </table>
  82. <?php endif; ?>
  83. <?php if ( !is_multisite() ) : ?>
  84. <h2 class="title"><?php _e('Uploading Files'); ?></h2>
  85. <table class="form-table">
  86. <?php
  87. // If upload_url_path is not the default (empty), and upload_path is not the default ('wp-content/uploads' or empty)
  88. if ( get_option('upload_url_path') || ( get_option('upload_path') != 'wp-content/uploads' && get_option('upload_path') ) ) :
  89. ?>
  90. <tr>
  91. <th scope="row"><label for="upload_path"><?php _e('Store uploads in this folder'); ?></label></th>
  92. <td><input name="upload_path" type="text" id="upload_path" value="<?php echo esc_attr(get_option('upload_path')); ?>" class="regular-text code" />
  93. <p class="description"><?php
  94. /* translators: %s: wp-content/uploads */
  95. printf( __( 'Default is %s' ), '<code>wp-content/uploads</code>' );
  96. ?></p>
  97. </td>
  98. </tr>
  99. <tr>
  100. <th scope="row"><label for="upload_url_path"><?php _e('Full URL path to files'); ?></label></th>
  101. <td><input name="upload_url_path" type="text" id="upload_url_path" value="<?php echo esc_attr( get_option('upload_url_path')); ?>" class="regular-text code" />
  102. <p class="description"><?php _e('Configuring this is optional. By default, it should be blank.'); ?></p>
  103. </td>
  104. </tr>
  105. <tr>
  106. <td colspan="2" class="td-full">
  107. <?php else : ?>
  108. <tr>
  109. <td class="td-full">
  110. <?php endif; ?>
  111. <label for="uploads_use_yearmonth_folders">
  112. <input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1"<?php checked('1', get_option('uploads_use_yearmonth_folders')); ?> />
  113. <?php _e('Organize my uploads into month- and year-based folders'); ?>
  114. </label>
  115. </td>
  116. </tr>
  117. <?php do_settings_fields('media', 'uploads'); ?>
  118. </table>
  119. <?php endif; ?>
  120. <?php do_settings_sections('media'); ?>
  121. <?php submit_button(); ?>
  122. </form>
  123. </div>
  124. <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>