fix svg thumbnails and non-png copy/pastes (#7348)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
575864c917
Коммит
c4e32060be
@@ -9,7 +9,7 @@ import loadingGif from 'images/load.gif';
|
|||||||
import Constants from 'utils/constants.jsx';
|
import Constants from 'utils/constants.jsx';
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
|
|
||||||
import {getFileThumbnailUrl} from 'mattermost-redux/utils/file_utils';
|
import {getFileUrl, getFileThumbnailUrl} from 'mattermost-redux/utils/file_utils';
|
||||||
|
|
||||||
export default class FilePreview extends React.Component {
|
export default class FilePreview extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -47,7 +47,14 @@ export default class FilePreview extends React.Component {
|
|||||||
|
|
||||||
let className = 'file-preview';
|
let className = 'file-preview';
|
||||||
let previewImage;
|
let previewImage;
|
||||||
if (type === 'image' || type === 'svg') {
|
if (type === 'svg') {
|
||||||
|
previewImage = (
|
||||||
|
<img
|
||||||
|
className='post-image normal'
|
||||||
|
src={getFileUrl(info.id)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else if (type === 'image') {
|
||||||
let imageClassName = 'post-image';
|
let imageClassName = 'post-image';
|
||||||
|
|
||||||
if (info.width < Constants.THUMBNAIL_WIDTH && info.height < Constants.THUMBNAIL_HEIGHT) {
|
if (info.width < Constants.THUMBNAIL_WIDTH && info.height < Constants.THUMBNAIL_HEIGHT) {
|
||||||
|
|||||||
@@ -250,11 +250,7 @@ class FileUpload extends React.Component {
|
|||||||
for (let i = 0; i < e.clipboardData.items.length; i++) {
|
for (let i = 0; i < e.clipboardData.items.length; i++) {
|
||||||
const item = e.clipboardData.items[i];
|
const item = e.clipboardData.items[i];
|
||||||
|
|
||||||
if (item.type.indexOf('image') === -1) {
|
if (item.kind !== 'file') {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Constants.IMAGE_TYPES.indexOf(item.type.split('/')[1].toLowerCase()) === -1) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,8 +275,9 @@ class FileUpload extends React.Component {
|
|||||||
|
|
||||||
for (var i = 0; i < items.length && i < numToUpload; i++) {
|
for (var i = 0; i < items.length && i < numToUpload; i++) {
|
||||||
var file = items[i].getAsFile();
|
var file = items[i].getAsFile();
|
||||||
|
if (!file) {
|
||||||
var ext = items[i].type.split('/')[1].toLowerCase();
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// generate a unique id that can be used by other components to refer back to this file upload
|
// generate a unique id that can be used by other components to refer back to this file upload
|
||||||
var clientId = Utils.generateId();
|
var clientId = Utils.generateId();
|
||||||
@@ -299,7 +296,8 @@ class FileUpload extends React.Component {
|
|||||||
min = String(d.getMinutes());
|
min = String(d.getMinutes());
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = formatMessage(holders.pasted) + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hour + '-' + min + '.' + ext;
|
const ext = file.name.lastIndexOf('.');
|
||||||
|
const name = formatMessage(holders.pasted) + d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hour + '-' + min + (ext >= 0 ? file.name.substr(ext) : '');
|
||||||
|
|
||||||
const request = uploadFile(
|
const request = uploadFile(
|
||||||
file,
|
file,
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user