Skip to content

Commit

Permalink
Slightly more defensive check
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Nov 20, 2024
1 parent dfdbc87 commit bf98e39
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public function one_pixel_fix( $image, $attachment_id, $size, $icon ) {
if ( get_post_mime_type( $attachment_id ) === 'image/svg+xml' ) {
$dimensions = $this->get_svg_dimensions( $attachment_id, $size );

if ( $dimensions && $dimensions['height'] && $dimensions['width'] ) {
if ( is_array( $dimensions ) && isset( $dimensions['height'], $dimensions['width'] ) ) {
$image[1] = $dimensions['width'];
$image[2] = $dimensions['height'];
} else {
Expand Down Expand Up @@ -502,7 +502,7 @@ public function get_image_tag_override( $html, $id, $alt, $title, $align, $size
if ( 'image/svg+xml' === $mime ) {
$dimensions = $this->get_svg_dimensions( $id, $size );

if ( $dimensions['height'] && $dimensions['width'] ) {
if ( is_array( $dimensions ) && isset( $dimensions['height'], $dimensions['width'] ) ) {
$html = str_replace( 'width="1" ', sprintf( 'width="%s" ', $dimensions['width'] ), $html );
$html = str_replace( 'height="1" ', sprintf( 'height="%s" ', $dimensions['height'] ), $html );
} else {
Expand Down Expand Up @@ -796,7 +796,6 @@ protected function get_svg_dimensions( $id, $size ) {

return $dimensions;
}

}
}

Expand Down

0 comments on commit bf98e39

Please sign in to comment.