PluginProbe
Assistant – Every Day Productivity Apps / 1.5.5.1
Assistant – Every Day Productivity Apps v1.5.5.1
1.5.5.1 1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 All 72 releases
← All changes | backend/src/Helpers/MediaPathHelper.php +19 -2 0.7.0.7 → 1.5.5.1 View file →
@@ -6,8 +6,17 @@
6 6
7 7 class MediaPathHelper {
8 8
9 9 /**
10 + * Array of data keys to ignore when parsing data.
11 + *
12 + * @var array
13 + */
14 + static private $data_blacklist = [
15 + '_seopress_analysis_data'
16 + ];
17 +
18 + /**
10 19 * Replaces the imported attachment in an object or array.
11 20 *
12 21 * @param object|array|string $data
13 22 * @param array $imported
@@ -187,11 +196,15 @@
187 196 * @param string $string
188 197 * @return array
189 198 */
190 199 static public function get_image_urls_from_string( $string ) {
191 - $pattern = '#https?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/)\.(jpg|jpeg|png|gif))#';
200 + $pattern = '#https?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/|_)\.(jpg|jpeg|png|gif|svg|webp))#';
192 201 $urls = [];
193 202
203 + if ( $string === null ) {
204 + return $urls;
205 + }
206 +
194 207 if ( preg_match_all( $pattern, $string, $matches ) ) {
195 208 if ( isset( $matches[0] ) && ! empty( $matches[0] ) ) {
196 209 $urls = $matches[0];
197 210 }
@@ -209,8 +222,12 @@
209 222 static public function get_image_urls_from_data( $data ) {
210 223 $urls = [];
211 224
212 225 foreach ( $data as $key => $val ) {
226 + if ( in_array( $key, self::$data_blacklist ) ) {
227 + continue;
228 + }
229 +
213 230 $val = maybe_unserialize( $val );
214 231
215 232 if ( is_object( $val ) || is_array( $val ) ) {
216 233 $urls = array_merge( $urls, self::get_image_urls_from_data( $val ) );
@@ -240,9 +257,9 @@
240 257 'height' => null,
241 258 'ext' => null,
242 259 ];
243 260
244 - preg_match_all( '/(-(\d+)x(\d+))\.(jpg|jpeg|png|gif)/', $url, $matches );
261 + preg_match_all( '/(-(\d+)x(\d+))\.(jpg|jpeg|png|gif|svg)/', $url, $matches );
245 262
246 263 if ( isset( $matches[1] ) && ! empty( $matches[1] ) ) {
247 264 $info['full_size_url'] = str_replace( $matches[1], '', $url );
248 265 }