Skip to content

Commit

Permalink
Merge pull request #174 from 10up/fix/75-slow-load-times-due-to-svgdi…
Browse files Browse the repository at this point in the history
…mensions-v2

fix width and height metadata condition on svg_dimensions function
  • Loading branch information
jeffpaul authored Mar 19, 2024
2 parents 7bdc8bc + 5900612 commit d4f9dcc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test-safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
),
),
)
);
Expand Down

0 comments on commit d4f9dcc

Please sign in to comment.