Skip to content

Commit

Permalink
Add a check to ensure our svg was loaded before we try getting it's d…
Browse files Browse the repository at this point in the history
…imensions
  • Loading branch information
dkotter committed Mar 25, 2024
1 parent d47a4a1 commit 741cc55
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,11 @@ protected function svg_dimensions( $attachment_id ) {
} elseif ( $svg ) {
$svg = @simplexml_load_file( $svg ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged

// Ensure the svg could be loaded.
if ( ! $svg ) {
return false;
}

$attributes = $svg->attributes();

if ( isset( $attributes->viewBox ) ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
Expand Down

0 comments on commit 741cc55

Please sign in to comment.