mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Handle image URLs with query parameters returned from an external barcode lookup plugin
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
- Optimizations in the built-in Open Food Facts external barcode lookup plugin:
|
||||
- A provided but empty localized product name is now ignored
|
||||
- Non-ASCII characters in product names are now ignored (e.g. line breaks caused problems)
|
||||
- Optimized that when an external barcode lookup plugin returned an image URL with query parameters, an invalid picture (file name) was added to the created product
|
||||
|
||||
### Shopping list
|
||||
|
||||
|
@@ -626,7 +626,7 @@ class StockService extends BaseService
|
||||
{
|
||||
$webClient = new Client();
|
||||
$response = $webClient->request('GET', $pluginOutput['__image_url'], ['headers' => ['User-Agent' => 'Grocy/' . $this->getApplicationService()->GetInstalledVersion()->Version . ' (https://grocy.info)']]);
|
||||
$fileName = $pluginOutput['__barcode'] . '.' . pathinfo($pluginOutput['__image_url'], PATHINFO_EXTENSION);
|
||||
$fileName = $pluginOutput['__barcode'] . '.' . pathinfo(parse_url($pluginOutput['__image_url'], PHP_URL_PATH), PATHINFO_EXTENSION);
|
||||
file_put_contents($this->getFilesService()->GetFilePath('productpictures', $fileName), $response->getBody());
|
||||
$productData['picture_file_name'] = $fileName;
|
||||
}
|
||||
|
Reference in New Issue
Block a user