Modify the default display settings of WordPress accessories

WordPress comment four hundred and sixty-two Reading mode

When WordPress adds an image to an article, there are three options in the default display settings of the attachment: alignment, link to, and size. Personally, after selecting once, the browser will remember the selection, and it is not necessary to select again next time. However, as WP developers are obsessed with block editors, they completely ignore the compatibility of other functions, and it seems that they are not very smart, When using the classic editor, it is really troublesome to select each time.

 Modify the default display settings of WordPress accessories

Modify the default display settings of WordPress accessories

section

Long ago, it was popular to add the following code in the topic function template functions.php to set the default values that you think fit.

 add_action( 'after_setup_theme', 'default_image_settings' ); function default_image_settings() { update_option( 'image_default_align', 'left' ); update_option( 'image_default_link_type', 'none' ); update_option( 'image_default_size', 'large' ); }

The final effect of the above code is the same as that of directly entering xxxx/wp admin/options.php and modifying the values of the following three items.

image_default_align
image_default_link_type
image_default_size

But I don't know when it has expired.

section

Currently available codes:

 add_action( 'admin_head-post.php', 'zm_reset_image_insert_settings' ); add_action( 'admin_head-post-new.php', 'zm_reset_image_insert_settings' ); function zm_reset_image_insert_settings() { ?> <script> if ( typeof setUserSetting !== 'undefined' ) { setUserSetting( 'align', 'center' ); //  none || left || center || right setUserSetting( 'imgsize', 'full' ); //  thumbnail || medium || large || full setUserSetting( 'urlbutton', 'file' ); //  none || file || post } </script> <? php }

Add it to the topic function template functions.php, and modify the default values of options that suit your needs.

Invalid for inserting picture from URL.

 

Most of the articles on this site are original and used for personal learning records, which may be helpful to you, for reference only!

 weinxin
My Wechat
Copyright Notice
Please indicate the source and link of the original article reprinted on this site. Thank you for your cooperation!
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 
 Robin
  • WordPress
five hundred and ninety-eight million eight hundred and forty-five thousand and six
 anonymous

Comment

Anonymous netizens
 :?:  :razz:  :sad:  :evil:  :!:  :smile:  :oops:  :grin:  :eek:  :shock:  :???:  :cool:  :lol:  :mad:  :twisted:  :roll:  :wink:  :idea:  :arrow:  :neutral:  :cry:  :mrgreen:

Drag the slider to complete validation