From 2e2c15d67fe49aedac4d7127da495f27a86cc7a8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Sep 2015 01:34:01 +0200 Subject: [PATCH 1/2] Minor fix to prevent a potential undefined variable notice. (and slight improvement to the regex) --- wp-tevko-responsive-images.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wp-tevko-responsive-images.php b/wp-tevko-responsive-images.php index b398c2d..cad8b19 100644 --- a/wp-tevko-responsive-images.php +++ b/wp-tevko-responsive-images.php @@ -342,13 +342,15 @@ function _tevkori_filter_content_images_callback( $image ) { } if ( $id && false === $size ) { - preg_match( '/width="([0-9]+)"/', $atts, $width ); - preg_match( '/height="([0-9]+)"/', $atts, $height ); - - $size = array( - (int) $width[1], - (int) $height[1] - ); + preg_match( '/ width="([0-9]+)"/', $atts, $width ); + preg_match( '/ height="([0-9]+)"/', $atts, $height ); + + if ( isset( $width[1] ) && isset( $height[1] ) ) { + $size = array( + (int) $width[1], + (int) $height[1] + ); + } } /* From ae2bcbf0e427ed66517d4a6f8638363b2f1ebc3d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Sep 2015 07:31:38 +0200 Subject: [PATCH 2/2] Merge three lines --- wp-tevko-responsive-images.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/wp-tevko-responsive-images.php b/wp-tevko-responsive-images.php index cad8b19..d2e8d79 100644 --- a/wp-tevko-responsive-images.php +++ b/wp-tevko-responsive-images.php @@ -342,10 +342,7 @@ function _tevkori_filter_content_images_callback( $image ) { } if ( $id && false === $size ) { - preg_match( '/ width="([0-9]+)"/', $atts, $width ); - preg_match( '/ height="([0-9]+)"/', $atts, $height ); - - if ( isset( $width[1] ) && isset( $height[1] ) ) { + if ( preg_match( '/ width="([0-9]+)"/', $atts, $width ) && preg_match( '/ height="([0-9]+)"/', $atts, $height ) ) { $size = array( (int) $width[1], (int) $height[1]