-1

What's the simplest way of getting wp_handle_upload

To either change the size of the image it is uploading, or to get WordPress to generate the 3 sized images like it does in "crunching" when adding new image in the media library?

I've seen some very complex solutions and really I want something much leaner! The best solution would be to get WordPress to automatically generate the thumbnail etc..

0

I hope I understood your question correctly. Image size are automatically generated according to thumbnail sizes set. For this to work correctly, you first need to add support for thumbnails, and then add any image size that you need inside your theme.

It is also important to know that you first add theme support and then add new image sizes as this will not work if you do this other way around. Also, image sizes are not generated for images already in the media library if new image sizes are added afterwards. Wordpress also don't make upsize(upscaled) versions of an image

I always add these functions inside a my initial theme setup function and then hook this function to the after_setup_theme hook.

Here is what your code should look like

function my_theme_setup() {
   add_theme_support( 'post-thumbnails' );
   add_image_size( 'homepage-thumb', 220, 180, true );
}

add_action( 'after_setup_theme', 'my_theme_setup' );

Remember, there is no need to add the default sizes, they are automatically included. You just need to add image sizes for custom thumbnails.

If you need to generate image sizes from images already in the media library, just download and install Force Regenarate Thumbnails to generate these extra image sizes.

EDIT

Unfortunately you don't repond to my comments, so I don't know if your problem is resolved or not. I stumpled upon another possible solution thanks to Adriano Batista in his question "WordPress Displaying Thumbnails Vertically"

I quote directly from his answer

For some reason my php_gd file was disabled in my php.ini file. I uncommented it, ran a regenerate thumbnails plugin in wordpress and viola! It all works now as it should.

| improve this answer | |
  • Thanks. Yes I think you did understand, the only thing is it isn't generating even the standard ones at the moment, only the original image is on the server? – tim.baker Apr 29 '14 at 11:37
  • Deleted my previous comment, I had my wording messed up. What happens if you deactivate all plugins and activate one of the default themes – Pieter Goosen Apr 29 '14 at 12:54

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.