diff --git a/safe-svg.php b/safe-svg.php index af20563..bf7b1c4 100644 --- a/safe-svg.php +++ b/safe-svg.php @@ -591,7 +591,7 @@ protected function svg_dimensions( $attachment_id ) { $width = 0; $height = 0; - if ( $svg && ! empty( $metadata['width'] ) && empty( $metadata['height'] ) ) { + if ( $svg && ! empty( $metadata['width'] ) && ! empty( $metadata['height'] ) ) { $width = floatval( $metadata['width'] ); $height = floatval( $metadata['height'] ); } elseif ( $svg ) { diff --git a/tests/unit/test-safe-svg.php b/tests/unit/test-safe-svg.php index ab56eae..4b52f6e 100644 --- a/tests/unit/test-safe-svg.php +++ b/tests/unit/test-safe-svg.php @@ -262,6 +262,9 @@ public function test_one_pixel_fix() { ), ), ), + array( + 'filesize' => 1001, // wp_get_attachment_metadata response for ./files/svgNoDimensions.svg file doesn't contain dimensions and sizes array. + ), ), ) );