mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
Propagate MIME type information (for SVG upload previews)
This commit is contained in:
parent
08b4889b31
commit
fbae2a9185
1 changed files with 3 additions and 2 deletions
|
@ -14,14 +14,14 @@ function scrapeUrl(url) {
|
|||
.then(response => response.json());
|
||||
}
|
||||
|
||||
function elementForEmbeddedImage({ camo_url }) {
|
||||
function elementForEmbeddedImage({ camo_url, type }) {
|
||||
// The upload was fetched from the scraper and is a path name
|
||||
if (typeof camo_url === 'string') {
|
||||
return makeEl('img', { className: 'scraper-preview--image', src: camo_url });
|
||||
}
|
||||
|
||||
// The upload was fetched from a file input and is an ArrayBuffer
|
||||
const objectUrl = URL.createObjectURL(new Blob([camo_url]));
|
||||
const objectUrl = URL.createObjectURL(new Blob([camo_url], { type }));
|
||||
const tagName = new DataView(camo_url).getUint32(0) === MATROSKA_MAGIC ? 'video' : 'img';
|
||||
return makeEl(tagName, { className: 'scraper-preview--image', src: objectUrl });
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ function setupImageUpload() {
|
|||
reader.addEventListener('load', event => {
|
||||
showImages([{
|
||||
camo_url: event.target.result,
|
||||
type: fileField.files[0].type
|
||||
}]);
|
||||
|
||||
// Clear any currently cached data, because the file field
|
||||
|
|
Loading…
Reference in a new issue