Skip to content

Commit

Permalink
Add image preview in Dropzone for SVG (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov authored Apr 8, 2024
1 parent b56fed7 commit a1e331d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/polaris_view_components.js
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ class Dropzone extends Controller {
this.element.classList.toggle("Polaris-DropZone--hasError", show);
}
renderFile(file) {
const validImageTypes = [ "image/gif", "image/jpeg", "image/png" ];
const validImageTypes = [ "image/gif", "image/jpeg", "image/png", "image/svg+xml" ];
const clone = this.itemTemplateTarget.content.cloneNode(true);
const [icon, thumbnail, content, fileSize] = [ clone.querySelector('[data-target="icon"]'), clone.querySelector('[data-target="thumbnail"]'), clone.querySelector('[data-target="content"]'), clone.querySelector('[data-target="file-size"]') ];
if (validImageTypes.includes(file.type)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export default class extends Controller {
}

renderFile (file) {
const validImageTypes = ['image/gif', 'image/jpeg', 'image/png']
const validImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml']
const clone = this.itemTemplateTarget.content.cloneNode(true)
const [icon, thumbnail, content, fileSize] = [
clone.querySelector('[data-target="icon"]'),
Expand Down

0 comments on commit a1e331d

Please sign in to comment.