options-media.php 6.1 KB

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