Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion web_src/js/features/repo-issue-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkd
import {createDropzone} from './dropzone.js';
import {GET, POST} from '../modules/fetch.js';
import {hideElem, showElem} from '../utils/dom.js';
import {isImageFile} from '../utils/image.js';
import {attachRefIssueContextPopup} from './contextpopup.js';
import {initCommentContent, initMarkupContent} from '../markup/content.js';

Expand Down Expand Up @@ -84,7 +85,9 @@ async function onEditContent(event) {
for (const attachment of data) {
const imgSrc = `${dropzone.getAttribute('data-link-url')}/${attachment.uuid}`;
dz.emit('addedfile', attachment);
dz.emit('thumbnail', attachment, imgSrc);
if (isImageFile(attachment.name)) {
dz.emit('thumbnail', attachment, imgSrc);
}
dz.emit('complete', attachment);
fileUuidDict[attachment.uuid] = {submitted: true};
dropzone.querySelector(`img[src='${imgSrc}']`).style.maxWidth = '100%';
Expand Down
4 changes: 4 additions & 0 deletions web_src/js/utils/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ export async function imageInfo(blob) {

return {width, dppx};
}

export function isImageFile(name) {
return /\.(jpe?g|png|gif|webp|svg|heic)$/i.test(name);
}