Index: /controller/wpsg_ProduktController.class.php
===================================================================
--- /controller/wpsg_ProduktController.class.php	(revision 6445)
+++ /controller/wpsg_ProduktController.class.php	(revision 6446)
@@ -78,9 +78,5 @@
 			else if ($_REQUEST['cmd'] == 'upload')
 			{ 
-				
-				// Tabelle Produkt postids lÃ¶schen
-				$sql = "UPDATE ".WPSG_TBL_PRODUCTS." SET `postids` = '' WHERE `id` = ".$_REQUEST['edit_id'];
-				$this->db->Query($sql);
-				
+			  				
 				add_post_meta($_REQUEST['post']['id'], 'wpsg_produkt_id', $_REQUEST['edit_id']);
 				
@@ -487,22 +483,31 @@
                         
                         // Bilder?
-						if (wpsg_isSizedInt($data['id']) && wpsg_isSizedArray($arImages[$data['id']]) && $this->shop->hasMod('wpsg_mod_produktbilder') && $this->shop->hasMod('wpsg_mod_produktbilder'))
+						if (wpsg_isSizedInt($data['id']) && wpsg_isSizedArray($arImages[$data['id']]))
                         {
                             
+							$arAttachmentIDs = $this->imagehandler->getAttachmentIDs($data['id']);
+							
                             foreach (array_reverse($arImages[$data['id']]) as $img)
                             {
                                 
+								$exist = false;
+								
                                 // PrÃŒfen ob ein Bild anhand des Namens schon im Produkt existiert
-                                $arImagesExists = $this->shop->callMod('wpsg_mod_produktbilder', 'getProduktBilder_MT', array($data['id'], 'full')); $exists = false;
-                                
-                                foreach ($arImagesExists as $k => $v)
-                                {
-                                
-                                    if (strtolower($v['basename']) === strtolower($img)) { $exists = true; break; }
-                                    
-                                }
-                                
-                                if (!$exists) $this->shop->callMod('wpsg_mod_produktbilder', 'addImageToProduct', array($extract_dir.'/'.$data['id'].'/'.$img, $data['id']));
-                                
+								foreach ($arAttachmentIDs as $attachment_id)
+								{
+									
+									$file = get_attached_file($attachment_id);
+									
+									if (strtolower(basename($file)) == strtolower($img)) { $exist = true; break; }
+									
+								}
+								
+								if (!$exist)
+								{
+									
+									$this->imagehandler->addImageToProduct($extract_dir.'/'.$data['id'].'/'.$img, $data['id']);
+									
+								}
+								
                             }
                                                            
Index: /lib/wpsg_imagehandler.class.php
===================================================================
--- /lib/wpsg_imagehandler.class.php	(revision 6445)
+++ /lib/wpsg_imagehandler.class.php	(revision 6446)
@@ -39,4 +39,36 @@
 			
 		} // public function getAttachmentID($product_key)
+		
+		public function addImageToProduct($file, $product_id)
+		{
+			
+			// Siehe
+			// https://codex.wordpress.org/Function_Reference/wp_insert_attachment
+			
+			$wp_upload_dir = wp_upload_dir();
+			
+			$mt_filetype = wp_check_filetype(basename($file), null);
+			$mt_filename = $wp_upload_dir['path'].'/'.basename($file);
+			
+			copy($file, $mt_filename);
+			
+			$attachment = array(
+				'guid' => wpsg_q($wp_upload_dir['url'].'/'.basename($file)),
+				'post_mime_type' => wpsg_q($mt_filetype['type']),
+				'post_title' => wpsg_q(preg_replace('/\.[^.]+$/', '', basename($file))),
+				'post_excerpt' => wpsg_q(basename($file)),
+				'post_status' => 'inherit'
+			);
+			
+			$attachment_id = wp_insert_attachment($attachment, $mt_filename, '0');
+			
+			require_once(ABSPATH.'wp-admin/includes/image.php');
+			
+			$attach_data = wp_generate_attachment_metadata($attachment_id, $mt_filename);
+			wp_update_attachment_metadata($attachment_id, $attach_data);
+			
+			add_post_meta($attachment_id, 'wpsg_produkt_id', $product_id);
+			
+		} // public function addImageToProduct($file, $product_id)
 		
 		/**
