title: magento addImageToMediaGallery is not working
body: <p>i was trying to add images into magento products programmatically but no luck.</p>
  
  <p>i find the function addImageToMediaGallery can do that but its not working </p>
  
  <pre><code>$p = Mage::getModel('catalog/product')-&gt;load($id);
  
  // save product 
  foreach ($imgs as $k =&gt; $img) {
  
  
      $img_path = Mage::getBaseDir('media'). $img;
      if( !$k ) {
          $p-&gt;addImageToMediaGallery( $img_path , array('small_image', 'thumbnail', 'image'), false, false);
      } else {
          $p-&gt;addImageToMediaGallery( $img_path , array(), false, false);
      }
      $p-&gt;save();
  
  }
  </code></pre>
  
  <p>what i know</p>
  
  <ul>
  <li><p>product is loading successfully i try <code>$p-&gt;getName()</code> and i get the title</p></li>
  <li><p>the paths are correct, images do live in <code>/home/tronixco/public_html/caskyco/media/temp_images/dji_phantom_4_drone_4k_hd_camerea_3_axis_gimbal_5km_range_with_28_minutes_flight_time_manfrotto_bag_pack_4_.jpg</code> </p></li>
  <li><p><strong>addImageToMediaGallery</strong> is doing some work as it copy the images to <code>catalog/product/d/j...</code></p></li>
  <li><p>in the admin panel product_edit there is nothing , like no image have been uploaded what so ever </p></li>
  <li><p>im running an external script and not getting any logs in var folder neither any error in error_logs files </p></li>
  <li><p>this whole code is running inside a function <code>product_add_images( $id , $images )</code></p></li>
  </ul>
  
  <p>magneto version is 1.9.2.4</p>