Support » Plugins » [Plugin: Scissors] wp_insert_attachment & Division by Zero

  • Resolved alkafy


    This is my first time toying with wp_insert_attachment; I need to mass-import several hundred images from a custom system. That said, the error is probably my fault and not a bug.

    Media Settings: 220×121 Thumbnail, 500×500 Medium, 1024×1024 Large.

    Here’s what I’m trying:

    $filename = $_SERVER[‘document_root’].’/wp-content/uploads/2009/05/conkle01.jpg’;

    $attachment = array(
    ‘guid’ => $filename,
    ‘post_title’ => ‘file’. time(),
    ‘post_content’ => ”,
    ‘post_type’ => ‘attachment’,
    ‘post_parent’ => 288,
    ‘post_mime_type’ => ‘image/jpeg’

    $attach_id = wp_insert_attachment($attachment, $filename, 288);
    $attach_data = wp_generate_attachment_metadata($attach_id, $filename);
    wp_update_attachment_metadata($attach_id, $attach_data);

    The image uploads to the Media management tab, but Scissors throws a Divison by Zero error. Have I missed a parameter for the $attachment object? Some other bonehead move on my part?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alkafy


    I need to file this question elsewhere. I don’t believe it to be a Scissors issue since the Media library reads 0x0, too. I’ve been trying to look into the image_make_intermediate_size function.. but I thought generate_attachment_metadata was supposed to cover it.

    Thread Starter alkafy


    Resolved here:

    Had the file path wrong – it would insert the attachment, but update_attachment_metadata would fail (which then failed to generate thumbnails or update the width/height records, causing the division by zero.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Scissors] wp_insert_attachment & Division by Zero’ is closed to new replies.