skip to Main Content

I have an intermittent issue. Sometimes the product creates okay with the image.

Note that all images tested do have file extensions and are external links that have valid paths with an image.

Sometimes the REST API (codexshaper/laravel-woocommerce package) throws this error:

"Error: #38761 is an invalid image ID. [woocommerce_product_invalid_image_id]"

It however still creates the product and image, but they’re not linked.
Can’t figure out why…

I even tried creating the product first then doing an update afterwards with the image, but it still only works sometimes.

{
   "sku":"889698487405",
   "name":"Star Wars: the Mandalorian Child Funko Pop! Vinyl Figure 368",
   "type":"simple",
   "regular_price":"299.00",
   "description":"Star Wars: The Mandalorian Child Funko Pop! Vinyl Figure 368: The Force is strong with this youngling. Adorable 3 3/4-inch tall Pop! Vinyl figure brings you The Child! Inspired by the Disney+ Star Wars: The Mandalorian TV series. Get the 10-Inch 'Super Size' Child Pop! too! Sold separately.",
   "short_description":"Star Wars: The Mandalorian Child Funko Pop! Vinyl Figure 368: The Force is strong with this youngling. Adorable 3 3/4-inch tall Pop! Vinyl figure brings you The Child! Inspired by the Disney+ Star Wars: The Mandalorian TV series. Get the 10-Inch 'Super Size' Child Pop! too! Sold separately.",
   "categories":[
      
   ],
   "images":[
      {
         "src":"https://images.barcodelookup.com/16285/162854082-1.jpg"
      }
   ],
   "status":"draft",
   "manage_stock":true,
   "stock_quantity":1,
   "stock_status":"instock"
}

2

Answers


  1. The problem in this case that the image you are using is PNG image not a JPG but the extension is .jpg this will cause this problem.

    The extension is not correct. you should retain the correct image extension or convert it to the wanted format.

    enter image description here

    Login or Signup to reply.
  2. Your image is PNG but url describes it as JPG.

    Error comes from WP Validation logic, because wordpress is parsing extension from url.

    If you would leave it without extension (for example https://via.placeholder.com/350×150) it would probably throw an error, you can work around this with:

    define('ALLOW_UNFILTERED_UPLOADS', true);
    

    placed in wp-config.php of your wordpress app.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search