How can I add a custom image upload size with a width of 550px and make it selected by default in the Add Media page?
Currently, there are 4 sizes available: Thumbnail
, Medium
, Large
and Full Size
. The Full Size
option is selected by default.
Anyone knows a working solution to this?
There are a few steps to this, as I found out today. First, you add a custom image size (you can put this somewhere the
functions.php
file in your theme):The unfortunate thing is that WordPress doesn’t actually show this new size in the media uploader. You’ll have to put a function that does this into your
functions.php
as well (source: http://kucrut.org/insert-image-with-custom-size-into-post/):Lastly, to set this size as the default, you’ll need to change a WordPress setting. Add a filter on the setting in question. This has the benefit of being portable with your theme in which you’ve defined all the above options.
I tested this all out on WordPress 3.4.2, and it seems to work great.
Note: I’d recommend putting the above PHP code into an init function of some sort and attaching it to the
'after_setup_theme'
hook:Just set all other options to
0
in your Admin panel under “Settings” » “Media”. This will disable them.