Skip to content

Commit 1ea8d1a

Browse files
committed
Extract SVG image dimensions
1 parent 7b215c2 commit 1ea8d1a

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/Support/ImageTransformers/Imgix.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ protected function extractMetaDetails(): void
132132
if ($dimensions) {
133133
if (Str::endsWith(strtolower($this->image->content()['filename']), '.svg')) {
134134
$this->meta = [
135-
'height' => false,
136-
'width' => false,
135+
'height' => $dimensions[0]['height'],
136+
'width' => $dimensions[0]['width'],
137137
'extension' => 'svg',
138138
'mime' => 'image/svg+xml',
139139
];
@@ -147,4 +147,4 @@ protected function extractMetaDetails(): void
147147
}
148148
}
149149
}
150-
}
150+
}

src/Support/ImageTransformers/Storyblok.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ protected function extractMetaDetails(): void
179179
if ($dimensions) {
180180
if (Str::endsWith(strtolower($this->image->content()['filename']), '.svg')) {
181181
$this->meta = [
182-
'height' => null,
183-
'width' => null,
182+
'height' => $dimensions[0]['height'],
183+
'width' => $dimensions[0]['width'],
184184
'extension' => 'svg',
185185
'mime' => 'image/svg+xml',
186186
];
@@ -217,4 +217,4 @@ protected function assetDomain($options = null): string
217217

218218
return $resource . '/m' . $options;
219219
}
220-
}
220+
}

src/Support/ImageTransformers/StoryblokSvg.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ protected function extractMetaDetails(): void
1717
preg_match_all('/(?<width>\d+)x(?<height>\d+).+\.(?<extension>[a-z]{3,4})/mi', $path, $dimensions, PREG_SET_ORDER, 0);
1818

1919
$this->meta = [
20-
'height' => null,
21-
'width' => null,
20+
'height' => $dimensions[0]['height'],
21+
'width' => $dimensions[0]['width'],
2222
'extension' => 'svg',
2323
'mime' => 'image/svg+xml',
2424
];

0 commit comments

Comments
 (0)