QQWorld Auto Save Images - Version 1.7.12.3

Version Description

Download this release

Release Info

Developer qqworld
Plugin Icon 128x128 QQWorld Auto Save Images
Version 1.7.12.3
Comparing to
See all releases

Code changes from version 1.7.12.2 to 1.7.12.3

Files changed (1) hide show
  1. qqworld-auto-save-images.php +17 -2
qqworld-auto-save-images.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: QQWorld Auto Save Images
4
  Plugin URI: https://wordpress.org/plugins/qqworld-auto-save-images/
5
  Description: Automatically keep the all remote picture to the local, and automatically set featured image.
6
- Version: 1.7.12.2
7
  Author: Michael Wang
8
  Author URI: http://www.qqworld.org
9
  Text Domain: qqworld_auto_save_images
@@ -1154,10 +1154,25 @@ class QQWorld_auto_save_images {
1154
  return array($file, $width, $height);
1155
  }
1156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1157
  //save exterior images
1158
  function save_images($image_url, $post_id){
1159
  set_time_limit(0);
1160
- if ( $file=@file_get_contents($image_url) ) {
 
1161
  $filename = $this->get_filename_from_url($image_url);
1162
  preg_match( '/(.*?)(\.(jpg|jpeg|png|gif|bmp))$/i', $filename, $match );
1163
  if ( empty($match) ) {
3
  Plugin Name: QQWorld Auto Save Images
4
  Plugin URI: https://wordpress.org/plugins/qqworld-auto-save-images/
5
  Description: Automatically keep the all remote picture to the local, and automatically set featured image.
6
+ Version: 1.7.12.3
7
  Author: Michael Wang
8
  Author URI: http://www.qqworld.org
9
  Text Domain: qqworld_auto_save_images
1154
  return array($file, $width, $height);
1155
  }
1156
 
1157
+ public function download_image($image_url) {
1158
+ if (function_exists('curl_init')) {
1159
+ $ch = curl_init();
1160
+ $timeout = 5;
1161
+ curl_setopt($ch, CURLOPT_URL, $image_url);
1162
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
1163
+ $file = curl_exec($ch);
1164
+ curl_close($ch);
1165
+ } else {
1166
+ $file = @file_get_contents($image_url);
1167
+ }
1168
+ return $file;
1169
+ }
1170
+
1171
  //save exterior images
1172
  function save_images($image_url, $post_id){
1173
  set_time_limit(0);
1174
+ $file = $this->download_image($image_url);
1175
+ if ( $file ) {
1176
  $filename = $this->get_filename_from_url($image_url);
1177
  preg_match( '/(.*?)(\.(jpg|jpeg|png|gif|bmp))$/i', $filename, $match );
1178
  if ( empty($match) ) {