1

I would like to set default values of the media variables on my multisite. If I want to do this on one site, it's a simple thing, I add values on mysite.com/wp-admin/options.php to the image_default_align, image_default_link_type and image_default_size, but I cannot add network global values for these.

So I want to edit it manually the core file: /wp-admin/options.php, but I dont know, how to do this, This level of the php is dont in my line.

Here is the code, which is listing the variables, but for these originally dont order to values:

$whitelist_options = array(
    'general' => array(
        'blogname',
        'blogdescription',
        'gmt_offset',
        'date_format',
        'time_format',
        'start_of_week',
        'timezone_string',
        'WPLANG',
        'new_admin_email'
    ),
    'discussion' => array(
        'default_pingback_flag',
        'default_ping_status',
        'default_comment_status',
        'comments_notify',
        'moderation_notify',
        'comment_moderation',
        'require_name_email',
        'comment_whitelist',
        'comment_max_links',
        'moderation_keys',
        'blacklist_keys',
        'show_avatars',
        'avatar_rating',
        'avatar_default',
        'close_comments_for_old_posts',
        'close_comments_days_old',
        'thread_comments',
        'thread_comments_depth',
        'page_comments',
        'comments_per_page',
        'default_comments_page',
        'comment_order',
        'comment_registration'
    ),
    'media' => array(
        'thumbnail_size_w',
        'thumbnail_size_h',
        'thumbnail_crop',
        'medium_size_w',
        'medium_size_h',
        'large_size_w',
        'large_size_h',
        'image_default_size',
        'image_default_align',
        'image_default_link_type'
    ),
    'reading' => array(
        'posts_per_page',
        'posts_per_rss',
        'rss_use_excerpt',
        'show_on_front',
        'page_on_front',
        'page_for_posts',
        'blog_public'
    ),
    'writing' => array(
        'default_category',
        'default_email_category',
        'default_link_category',
        'default_post_format'
    )
);

The major part this:

    'media' => array(
        'thumbnail_size_w',
        'thumbnail_size_h',
        'thumbnail_crop',
        'medium_size_w',
        'medium_size_h',
        'large_size_w',
        'large_size_h',
        'image_default_size',
        'image_default_align',
        'image_default_link_type'
    ),

Here is an example, where (I think) the code ordering values to the variable: $whitelist_options['general'][] = 'siteurl';

I did not manage to do that...

1

firstly, don't edit core files of WordPress or your changes will be erased at the next update.


in the file options.php look below this array declaration, you have this line :

$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );

that means that you can custom this array with this code in a plugin or the theme :

add_filter("whitelist_options", function ($whitelist_options) {

    $whitelist_options["general"][] = "siteurl";

    return $whitelist_options;

});
  • Thank you, your guidelines I found it, what I searched: add_action( 'after_setup_theme', 'wnd_default_image_settings' ); function wnd_default_image_settings() { update_option( 'image_default_align', 'center' ); update_option( 'image_default_link_type', 'file' ); update_option( 'image_default_size', 'full-size' ); } Other options: image_default_align: left, right, center, none image_default_link_type: file, page, none image_default_size: thumbnail, medium, large, full-size – Galgóczi Levente Jan 25 '18 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.