options-media.php 6.2 KB

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