Is there any extension that give us the possibility to add external url instead of a base64 string when I adding/update product via magento 2 api?
-
Not sure about it, but what if you convert the img to base 64 using the img url, I think you can do that as well.– fmsthirdCommented Nov 18, 2020 at 7:36
-
I try to convert the img url to base 64 but magento don't like it :-) imgur.com/oTxMZ7h Error -> The image content must be valid base64 encoded data.– SebCommented Nov 18, 2020 at 7:47
-
nah I mean get the contents of the img url then convert it to base_64– fmsthirdCommented Nov 18, 2020 at 7:59
-
were you able to fix it?– fmsthirdCommented Nov 18, 2020 at 11:01
Add a comment
|
1 Answer
an extension is available you can check this https://github.com/olivertar/m2_api_product_images
also, you can update that as per your need
remove if condition here and update with following
$imagedata = file_get_contents($entry['file']);
if($imagedata){
$entry['content'][ImageContentInterface::BASE64_ENCODED_DATA] = base64_encode($imagedata);
$mediaGalleryEntries[$k]['content'][ImageContentInterface::BASE64_ENCODED_DATA] = base64_encode($imagedata);
}
-
thx for that. But here I need to upload the file in media folder first. I need a external url like example.com/test.jpeg that I can use in the api– SebCommented Nov 18, 2020 at 7:40
-
you can update that with your logic here github.com/olivertar/m2_api_product_images/blob/master/… Commented Nov 18, 2020 at 8:20