• Hello everyone, this is my first post here.

    I am hoping to get some help with generation of thumbnails for an image in the upload folder.

    I’ve read every post on wp_insert_attachment(), wp_generate_attachment_metadata(), and wp_update_attachment_metadata() and tried everything, but I cannot get the thumbnails to generate, and I think it’s because something is going wrong with the image_make_intermediate_size() function.

    I believe I’ve traced the error to the image.php file and wp_generate_attachment_metadata() function, which calls:

    $resized = image_make_intermediate_size( $file, $size_data['width'], $size_data['height'], $size_data['crop'] );
    echo $resized;

    I put in the echo, and even though I’ve verified that $file, $size_data are all specified and valid arguments, the image_make_intermediate_size() function never creates the thumbnail or returns “false” either, for that matter.

    I’ve checked directory permissions, they are 755 on that folder. I’m using standard code to call the thumbnail creation functions:

    // Create post object
    $my_post = array(
      'post_title'  => 'Title.',
      'post_content'  => 'This is my post.',
      'post_status'   => 'inherit',
      'post_author'   => $post_user,
      'post_parent'   => $post_parent,
      'post_mime_type' => 'image/jpeg',
      'post_type' => 'attachment',
      'guid' => $filepath,
    );
    $attach_id = wp_insert_attachment( $my_post, $filepath, $post_parent );
    $attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
    wp_update_attachment_metadata( $attach_id,  $attach_data );

    Any ideas why the image_make_intermediate_size() function seems not to be working? Thanks!
    Shawn

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter brighthelix

    (@brighthelix)

    I know the thumbnails can be generated correctly on that server, because my gravity forms installation is able to create images, thumbnails, and the correct metadata.

    Thread Starter brighthelix

    (@brighthelix)

    Hello, anyone around?

    Thread Starter brighthelix

    (@brighthelix)

    Okay, figured it out!

    The reason it was happening was because I was specifying the filepath argument to wordpress as:

    $wp_upload_dir[‘url’]
    Returning the absolute path with https://. Somehow WordPress was never able to find the file.

    now I use:
    $wp_upload_dir[‘path’]
    Which returns the absolute path with /home/etc…
    Wordpress likes this better.

    Anyone know why?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘image_make_intermediate_size() broken? Doesn't make thumbnails.’ is closed to new replies.