Curl replacement for file_get_contents
-
Please add a CURL replacemente for file_get_contents function, so the plugin can work even on hosting with
allow_url_fopen=0
.I’ve added a public function in class.attachment.php
public function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec($ch); curl_close($ch); return $data; }
and changed the call on line 270 to
$optimized_file = $this->file_get_contents_curl( $optimized_img_url );
(code for function file_get_contents_curl taken here)
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Curl replacement for file_get_contents’ is closed to new replies.