WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Scissors] wp_insert_attachment & Division by Zero (3 posts)

  1. alkafy
    Member
    Posted 5 years ago #

    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: 220x121 Thumbnail, 500x500 Medium, 1024x1024 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?

    http://wordpress.org/extend/plugins/scissors/

  2. alkafy
    Member
    Posted 5 years ago #

    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.

  3. alkafy
    Member
    Posted 5 years ago #

    Resolved here: http://wordpress.org/support/topic/282024?replies=8

    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.)

Topic Closed

This topic has been closed to new replies.

About this Topic