Skip to content

Commit

Permalink
Merge pull request Expensify#15037 from Ollyws/issue-13038
Browse files Browse the repository at this point in the history
Fix for: Figure out why svg images don't show immediately when uploading as avatar
  • Loading branch information
Beamanator authored Feb 14, 2023
2 parents e31cb53 + ceab0f6 commit 1a5249d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const CONST = {

AVATAR_MAX_ATTACHMENT_SIZE: 6291456,

AVATAR_ALLOWED_EXTENSIONS: ['jpg', 'jpeg', 'png', 'gif', 'bmp'],
AVATAR_ALLOWED_EXTENSIONS: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg'],

// Minimum width and height size in px for a selected image
AVATAR_MIN_WIDTH_PX: 80,
Expand Down
8 changes: 7 additions & 1 deletion src/components/AvatarCropModal/AvatarCropModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,16 @@ const AvatarCropModal = (props) => {
height: size, width: size, originX, originY,
};

// Svg images are converted to a png blob to preserve transparency, so we need to update the
// image name and type accordingly.
const isSvg = props.imageType.includes('image/svg');
const imageName = isSvg ? 'fileName.png' : props.imageName;
const imageType = isSvg ? 'image/png' : props.imageType;

cropOrRotateImage(
props.imageUri,
[{rotate: rotation.value % 360}, {crop}],
{compress: 1, name: props.imageName, type: props.imageType},
{compress: 1, name: imageName, type: imageType},
)
.then((newImage) => {
props.onClose();
Expand Down

0 comments on commit 1a5249d

Please sign in to comment.