Version Description
Download this release
Release Info
Developer | qqworld |
Plugin | QQWorld Auto Save Images |
Version | 1.7.12.7 |
Comparing to | |
See all releases |
Code changes from version 1.7.12.6 to 1.7.12.7
- qqworld-auto-save-images.php +20 -8
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.
|
7 |
Author: Michael Wang
|
8 |
Author URI: http://www.qqworld.org
|
9 |
Text Domain: qqworld_auto_save_images
|
@@ -985,9 +985,13 @@ class QQWorld_auto_save_images {
|
|
985 |
}
|
986 |
|
987 |
public function content_save_pre($content, $post_id=null, $action='save') {
|
988 |
-
$
|
989 |
-
|
990 |
-
|
|
|
|
|
|
|
|
|
991 |
if(empty($image_url)) continue;
|
992 |
// exclude domain
|
993 |
$allow=true;
|
@@ -1076,10 +1080,18 @@ class QQWorld_auto_save_images {
|
|
1076 |
|
1077 |
public function set_img_metadata($img, $attachment_id) {
|
1078 |
if ($this->change_title_alt == 'no') {
|
1079 |
-
$pattern = '/<img\s[^>]*alt
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1083 |
} else {
|
1084 |
$alt = $this->get_post_title() ? $this->get_post_title() : null;
|
1085 |
$title = $this->get_post_title() ? $this->get_post_title() : null;
|
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.7
|
7 |
Author: Michael Wang
|
8 |
Author URI: http://www.qqworld.org
|
9 |
Text Domain: qqworld_auto_save_images
|
985 |
}
|
986 |
|
987 |
public function content_save_pre($content, $post_id=null, $action='save') {
|
988 |
+
$remote_images = array();
|
989 |
+
$preg = preg_match_all('/<img.*?src=\"((?!\").*?)\"/i', stripslashes($content), $matches);
|
990 |
+
if ($preg) $remote_images = $matches[1];
|
991 |
+
$preg = preg_match_all('/<img.*?src=\'((?!\').*?)\'/i', stripslashes($content), $matches);
|
992 |
+
if ($preg) $remote_images = array_merge($remote_images, $matches[1]);
|
993 |
+
if(!empty($remote_images)){
|
994 |
+
foreach($remote_images as $image_url) {
|
995 |
if(empty($image_url)) continue;
|
996 |
// exclude domain
|
997 |
$allow=true;
|
1080 |
|
1081 |
public function set_img_metadata($img, $attachment_id) {
|
1082 |
if ($this->change_title_alt == 'no') {
|
1083 |
+
$pattern = '/<img\s[^>]*alt=\"(.*?)\".*?>/i';
|
1084 |
+
if ( preg_match($pattern, $img, $matches) ) $alt = $matches[1];
|
1085 |
+
else {
|
1086 |
+
$pattern = '/<img\s[^>]*alt=\'(.*?)\'.*?>/i';
|
1087 |
+
$alt = preg_match($pattern, $img, $matches) ? $matches[1] : null;
|
1088 |
+
}
|
1089 |
+
$pattern = '/<img\s[^>]*title=\"(.*?)\".*?>/i';
|
1090 |
+
if ( preg_match($pattern, $img, $matches) ) $title = $matches[1];
|
1091 |
+
else {
|
1092 |
+
$pattern = '/<img\s[^>]*alt=\'(.*?)\'.*?>/i';
|
1093 |
+
$title = preg_match($pattern, $img, $matches) ? $matches[1] : null;
|
1094 |
+
}
|
1095 |
} else {
|
1096 |
$alt = $this->get_post_title() ? $this->get_post_title() : null;
|
1097 |
$title = $this->get_post_title() ? $this->get_post_title() : null;
|