Title: [Plugin: Scissors] wp_insert_attachment &amp; Division by Zero
Last modified: August 19, 2016

---

# [Plugin: Scissors] wp_insert_attachment & Division by Zero

 *  Resolved [alkafy](https://wordpress.org/support/users/alkafy/)
 * (@alkafy)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/plugin-scissors-wp_insert_attachment-amp-division-by-zero/)
 * 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?
 * [http://wordpress.org/extend/plugins/scissors/](http://wordpress.org/extend/plugins/scissors/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [alkafy](https://wordpress.org/support/users/alkafy/)
 * (@alkafy)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/plugin-scissors-wp_insert_attachment-amp-division-by-zero/#post-1113907)
 * 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](https://wordpress.org/support/users/alkafy/)
 * (@alkafy)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/plugin-scissors-wp_insert_attachment-amp-division-by-zero/#post-1114079)
 * Resolved here: [http://wordpress.org/support/topic/282024?replies=8](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.)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: Scissors] wp_insert_attachment & Division by Zero’ is closed
to new replies.

 * 2 replies
 * 1 participant
 * Last reply from: [alkafy](https://wordpress.org/support/users/alkafy/)
 * Last activity: [16 years, 11 months ago](https://wordpress.org/support/topic/plugin-scissors-wp_insert_attachment-amp-division-by-zero/#post-1114079)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
