1
0
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:
Daniel Waxweiler
2025-05-23 22:07:33 +02:00
parent 10f4f3eceb
commit 40f259d817
2 changed files with 3 additions and 20 deletions

View File

@ -5,6 +5,7 @@
- Add settings link to plugin on plugins page
- Add donation link to plugin on plugins page
#### Changed
- Use wp_remote_get() instead of cURL functions for downloading the images
#### Deprecated
#### Removed
#### Fixed

View File

@ -145,26 +145,8 @@ final class GraphQlClient {
}
private static function download_image($url) {
// Initialize curl handle
$ch = curl_init($url);
// 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);
$response = wp_remote_get($url);
$image_data = $response['body'];
return $image_data;
}
}