Skip to content

Commit

Permalink
fix(asset-server-plugin): Fix corrupt SVG previews
Browse files Browse the repository at this point in the history
Closes #456
  • Loading branch information
michaelbromley committed Jan 14, 2021
1 parent a6f3083 commit 3a16d87
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export class SharpAssetPreviewStrategy implements AssetPreviewStrategy {
if (maxWidth < width || maxHeight < height) {
return image.resize(maxWidth, maxHeight, { fit: 'inside' }).toBuffer();
} else {
return data;
if (mimeType === 'image/svg+xml') {
// Convert the SVG to a raster for the preview
return image.toBuffer();
} else {
return data;
}
}
} else {
return sharp(path.join(__dirname, 'file-icon.png'))
Expand Down

0 comments on commit 3a16d87

Please sign in to comment.