[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> options-media.php (source)

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


Generated : Fri Oct 10 08:20:03 2025 Cross-referenced by PHPXref