mirror of
https://github.com/strapi/strapi.git
synced 2025-08-18 05:37:10 +00:00
Fixes #1518
This commit is contained in:
parent
b48dced09d
commit
d319d22f91
@ -8,7 +8,7 @@
|
||||
/* eslint-disable no-console */
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { get, has, isArray, isEmpty, size } from 'lodash';
|
||||
import { get, has, isArray, isEmpty, startsWith, size } from 'lodash';
|
||||
import cn from 'classnames';
|
||||
|
||||
import BkgImg from 'assets/icons/icon_upload.svg';
|
||||
@ -31,9 +31,10 @@ class ImgPreview extends React.Component {
|
||||
componentDidMount() {
|
||||
// We don't need the generateImgURL function here since the compo will
|
||||
// always have an init value here
|
||||
const file = this.props.multiple ? get(this.props.files, ['0', 'name'], '') : get(this.props.files, 'name');
|
||||
this.setState({
|
||||
imgURL: get(this.props.files, ['0', 'url'], '') || get(this.props.files, 'url', ''),
|
||||
isImg: this.isPictureType(get(this.props.files, ['0', 'name'], '')),
|
||||
isImg: this.isPictureType(file),
|
||||
});
|
||||
}
|
||||
|
||||
@ -142,10 +143,12 @@ class ImgPreview extends React.Component {
|
||||
|
||||
renderContent = () => {
|
||||
const fileType = this.getFileType(this.state.imgURL);
|
||||
|
||||
|
||||
if (this.state.isImg) {
|
||||
const imgURL = startsWith(this.state.imgURL, '/') ? `${strapi.backendURL}${this.state.imgURL}` : this.state.imgURL;
|
||||
|
||||
return (
|
||||
<img src={this.state.imgURL} alt="" />
|
||||
<img src={imgURL} alt="" />
|
||||
);
|
||||
}
|
||||
|
||||
@ -159,6 +162,7 @@ class ImgPreview extends React.Component {
|
||||
render() {
|
||||
const { files, onBrowseClick } = this.props;
|
||||
const { imgURL } = this.state;
|
||||
|
||||
const containerStyle = isEmpty(imgURL) ?
|
||||
{
|
||||
backgroundImage: `url(${BkgImg})`,
|
||||
|
@ -14,6 +14,7 @@ import GlobalPagination from 'components/GlobalPagination';
|
||||
|
||||
import styles from './styles.scss';
|
||||
|
||||
/* eslint-disable jsx-a11y/label-has-for */
|
||||
function PageFooter(props) {
|
||||
return (
|
||||
<div className={cn('row', styles.pageFooter)} style={props.style}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user