mirror of
https://github.com/dwaxweiler/connector-mobilizon
synced 2025-06-05 21:59:25 +02:00
improve image downloading
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
- Add settings link to plugin on plugins page
|
- Add settings link to plugin on plugins page
|
||||||
- Add donation link to plugin on plugins page
|
- Add donation link to plugin on plugins page
|
||||||
#### Changed
|
#### Changed
|
||||||
|
- Use wp_remote_get() instead of cURL functions for downloading the images
|
||||||
#### Deprecated
|
#### Deprecated
|
||||||
#### Removed
|
#### Removed
|
||||||
#### Fixed
|
#### Fixed
|
||||||
|
@ -145,26 +145,8 @@ final class GraphQlClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static function download_image($url) {
|
private static function download_image($url) {
|
||||||
// Initialize curl handle
|
$response = wp_remote_get($url);
|
||||||
$ch = curl_init($url);
|
$image_data = $response['body'];
|
||||||
|
|
||||||
// Set curl options
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 60); // Set timeout to 60 seconds (adjust as needed)
|
|
||||||
|
|
||||||
// Execute the request
|
|
||||||
$image_data = curl_exec($ch);
|
|
||||||
|
|
||||||
// Check for errors
|
|
||||||
if (curl_errno($ch)) {
|
|
||||||
print_r(curl_error($ch));
|
|
||||||
throw new \Error('Error: ' . curl_error($ch));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close curl handle
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
return $image_data;
|
return $image_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user