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, with the WP developer's preoccupation with the block editor, he completely disregards the compatibility of other functions, and it seems that he is not very clever, When using the classic editor, it is really troublesome to select each time.
Modify the default display settings of WordPress accessories
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.
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!