When I upload an image, it is automatically resized as I would expect, however the sizes for inserting the image seem to ignore the settings I’ve placed in Settings/Media.
In my media settings I have:
- Thumbnail: 150 x 150
- Medium: 300 x 300
- Large: 690 x 9999
I upload an image of: 2226 x 1663.
Wordpress generates the correct image sizes, but gives me the following options for insertion:
- Thumbnail: 150 x 150 (as expected)
- Medium: 300 x 224 (as expected)
- Large: 640 x 447 (Wrong. Why?)
I looked on the forums and found a suggestion that I add the following to my functions.php file:
update_option('large_size_w', 690);
However, this did not work.
I believe your issue is that the value set for the global
$content_width
variable (which is 640px in Boilerplate and 584px in Twenty Eleven) is less than the width you’re specifying viaSettings -> Media
.WordPress is overriding your user setting with the Theme-specific value. This actually makes sense, since a Theme knows its maximum content width, and using a larger image width than what the Theme is designed to accommodate would very likely break the Theme layout.
The solution, then, if you need to change the large image width to 690px (and assuming your Child Theme can accommodate this width), is to define
$content_width
in your Child Themefunctions.php
file. I would recommend using a Child Theme setup function, hooked intoafter_setup_theme()
, like so:The priority 9 is probably overkill, since your Child Theme’s actions will be added before the parent Theme’s actions anyway; but using priority 9 will guarantee that this action fires before the parent Theme setup fires, at priority 10.
Since your Child Theme action fires first, the Child Theme defines
$content_width
, and the Parent Theme does not override it (since it also uses aif ( ! isset() )
conditional wrapper).Edit
So, looking at the Twenty Eleven
functions.php
file, I realized I made a bad assumption: Twenty Eleven defines$content_width
nakedly infunctions.php
, rather than inside the Theme setup function, hooked intoafter_setup_theme
. So, to override it, ** you have to do likewise**.Just put the following at the top of your
functions.php
file, before any other function definitions:This should work, since the Child Theme
functions.php
gets parsed before the Parent Themefunctions.php
.(This is a prime example of why Themes should wrap all the things inside callbacks. 🙂 )
Modify your settings on the media page so that your maximum embed width is 690 rather than blank
If you want more control on what image sizes are generated when you upload images, have a look at the Simple Image Sizes plugin