wip: fixing bugs in image uploads and display

This commit is contained in:
or-else
2020-10-15 17:36:35 -07:00
parent de1028e141
commit 738d84045d
8 changed files with 64 additions and 37 deletions
+10 -7
View File
@@ -174,7 +174,8 @@ function draftyFormatter(style, data, values, key) {
case 'IM':
// Additional processing for images
if (data) {
if (Drafty.isUploading(data)) {
const uploading = Drafty.isUploading(data);
if (uploading) {
// Use custom element instead of <img>.
el = 'UploadingImage';
}
@@ -183,12 +184,14 @@ function draftyFormatter(style, data, values, key) {
Math.min(this.props.viewportWidth - REM_SIZE * 4, REM_SIZE * 36), REM_SIZE * 24, false);
dim = dim || {dstWidth: BROKEN_IMAGE_SIZE, dstHeight: BROKEN_IMAGE_SIZE};
attr.style = { width: dim.dstWidth + 'px', height: dim.dstHeight + 'px' };
attr.src = sanitizeImageUrl(attr.src);
if (attr.src) {
attr.onClick = this.handleImagePreview;
attr.className += ' image-clickable';
} else {
attr.src = 'img/broken_image.png';
if (!uploading) {
attr.src = sanitizeImageUrl(attr.src);
if (attr.src) {
attr.onClick = this.handleImagePreview;
attr.className += ' image-clickable';
} else {
attr.src = 'img/broken_image.png';
}
}
}
break;