Skip to content

Commit

Permalink
Merge pull request #184 from jrfnl/feature/fix-undefined-notice
Browse files Browse the repository at this point in the history
Sanity check the `preg_match()` values for width/height before using.

Props @jrfnl
  • Loading branch information
joemcgill committed Sep 25, 2015
2 parents 4bc3295 + ae2bcbf commit 20301c7
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions wp-tevko-responsive-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,12 @@ 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]
);
if ( preg_match( '/ width="([0-9]+)"/', $atts, $width ) && preg_match( '/ height="([0-9]+)"/', $atts, $height ) ) {
$size = array(
(int) $width[1],
(int) $height[1]
);
}
}

/*
Expand Down

0 comments on commit 20301c7

Please sign in to comment.