Files
dotfiles/scaffolds/react-app-common/core/utils/image_utils.ts
2022-09-02 03:48:39 +03:00

17 lines
412 B
TypeScript

export function fallbackImageUrl(
text: string,
{ width, height }: Record<'width' | 'height', number>,
): string {
const qs = new URLSearchParams({
bg_color: '008000',
fg_color: 'FFFFFF',
text,
})
return `https://placeholder.photo/img/${width}x${height}?` + qs.toString()
}
export function apiFallbackImageUrl(url: string): string {
return `/api/image?url=${decodeURIComponent(url)}`
}