1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

displaying image nodes

This commit is contained in:
Fedor Katurov 2019-10-12 16:55:57 +07:00
parent c6ccbb0fb4
commit 09b4fbd7b6
3 changed files with 7 additions and 8 deletions

View file

@ -1,5 +1,4 @@
import React, { FC, useState, useCallback } from 'react'; import React, { FC, useState, useCallback } from 'react';
import { NavLink } from 'react-router-dom';
import { INode } from '~/redux/types'; import { INode } from '~/redux/types';
import { URLS } from '~/constants/urls'; import { URLS } from '~/constants/urls';
import { getImageSize } from '~/utils/dom'; import { getImageSize } from '~/utils/dom';
@ -38,11 +37,11 @@ const Cell: FC<IProps> = ({ node: { id, title, brief, type }, onSelect, is_text
<div <div
className={styles.thumbnail} className={styles.thumbnail}
style={{ style={{
backgroundImage: `url("${getImageSize(brief.thumbnail, 'medium')}")`, backgroundImage: `url("${brief.thumbnail}")`,
opacity: is_loaded ? 1 : 0, opacity: is_loaded ? 1 : 0,
}} }}
> >
<img src={getImageSize(brief.thumbnail, 'medium')} onLoad={onImageLoad} alt="" /> <img src={brief.thumbnail} onLoad={onImageLoad} alt="" />
</div> </div>
)} )}
</div> </div>

View file

@ -78,7 +78,7 @@ const NodeImageBlock: FC<IProps> = ({ node, is_loading }) => {
> >
<img <img
className={styles.image} className={styles.image}
src={getImageSize(file.url, 'node')} src={getImageSize(file, 'node')}
alt="" alt=""
key={file.id} key={file.id}
onLoad={onImageLoad(index)} onLoad={onImageLoad(index)}

View file

@ -58,12 +58,12 @@ export const getURL = (file: IFile) => {
if (!file || !file.url) return null; if (!file || !file.url) return null;
return file.url return file.url
.replace('REMOTE_OLD://', process.env.REMOTE_OLD) .replace('REMOTE_CURRENT://', process.env.REMOTE_CURRENT)
.replace('REMOTE_CURRENT://', process.env.REMOTE_CURRENT); .replace('REMOTE_OLD://', process.env.REMOTE_OLD);
}; };
export const getImageSize = (image: string, size?: string): string => export const getImageSize = (file: IFile, size?: string): string => getURL(file);
`${process.env.API_HOST}${image}`.replace('{size}', size); // `${process.env.API_HOST}${image}`.replace('{size}', size);
export const formatCommentText = (author, text: string) => export const formatCommentText = (author, text: string) =>
text text