Skip to content

Commit 74be3c1

Browse files
mendyEdriethanshar
andauthored
Maybe fix assets 2 (#2856)
* fix image svg * check for svg closing tag instead of checking only for string type * lint * Fix TS errors * check for svg data as well * ts * support both svg and image * lint * lint * split web and mobile * overlay * dynamic aspect-ratio * image fit * remove old web implementation * remove default alt image * revert lint * remove default alt * handle missing asset - alt * remove lint autofix * remove unsued * maybe fix assets * trying to fix build fails * fix lint * try fix ci * remove comment * try again * maybe without the specifc change in web * remove unused * source fix * added default size same as Icon * replace default size with aspectRatio * default aspect ratio only for web * aspectRatio by defaut and strech * fix build * trying to fix ci * maybe fix ci * Remove strech * lint * lint 2 * check svg only for web * PR review * lint --------- Co-authored-by: Ethan Sharabi <[email protected]>
1 parent 74e5ea2 commit 74be3c1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/components/image/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ class Image extends PureComponent<Props, State> {
207207
renderImage = (useImageInsideContainer: boolean) => {
208208
const {error} = this.state;
209209
const source = error ? this.getVerifiedSource(this.props.errorSource) : this.getImageSource();
210+
210211
const {
211212
tintColor,
212213
style,

src/utils/imageUtils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import get from 'lodash/get';
22
import {ImageProps} from 'react-native';
33
import Assets from '../assets';
4+
import {Constants} from '../commons/new';
45

56
export function isSvgUri(source?: ImageProps['source']) {
67
// @ts-expect-error
78
return typeof source === 'object' && source?.uri?.endsWith?.('.svg');
89
}
910

1011
export function isSvg(source?: ImageProps['source']) {
11-
return typeof source === 'string' || typeof source === 'function' || isSvgUri(source);
12+
return typeof source === 'function' || isSvgUri(source) || (Constants.isWeb && isSvgData(source));
1213
}
1314

1415
export function isBase64ImageContent(data: string) {
@@ -21,3 +22,7 @@ export function getAsset(assetName = '', assetGroup = '') {
2122
return get(Assets, `${assetGroup}.${assetName}`);
2223
}
2324

25+
function isSvgData(source?: ImageProps['source']) {
26+
const sourceString = (source as string);
27+
return typeof source === 'string' && (sourceString.includes('</svg>') || sourceString.includes('data:image/svg'));
28+
}

0 commit comments

Comments
 (0)