GitHub svg media library preview support (#954)
* Append sanitize query to svg download_url * Add svg ext to media viewable * Append searchParam manually
This commit is contained in:
parent
b927c8acfb
commit
b8c411ce28
@ -94,7 +94,11 @@ export default class GitHub {
|
|||||||
return this.api.listFiles(this.config.get('media_folder'))
|
return this.api.listFiles(this.config.get('media_folder'))
|
||||||
.then(files => files.filter(file => file.type === 'file'))
|
.then(files => files.filter(file => file.type === 'file'))
|
||||||
.then(files => files.map(({ sha, name, size, download_url, path }) => {
|
.then(files => files.map(({ sha, name, size, download_url, path }) => {
|
||||||
return { id: sha, name, size, url: download_url, path };
|
const url = new URL(download_url);
|
||||||
|
if (url.pathname.match(/.svg$/)) {
|
||||||
|
url.search += (url.search.slice(1) === '' ? '?' : '&') + 'sanitize=true';
|
||||||
|
}
|
||||||
|
return { id: sha, name, size, url: url.href, path };
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,8 @@ import { Icon } from 'UI';
|
|||||||
* Extensions used to determine which files to show when the media library is
|
* Extensions used to determine which files to show when the media library is
|
||||||
* accessed from an image insertion field.
|
* accessed from an image insertion field.
|
||||||
*/
|
*/
|
||||||
const IMAGE_EXTENSIONS_VIEWABLE = [ 'jpg', 'jpeg', 'webp', 'gif', 'png', 'bmp', 'tiff' ];
|
const IMAGE_EXTENSIONS_VIEWABLE = [ 'jpg', 'jpeg', 'webp', 'gif', 'png', 'bmp', 'tiff', 'svg' ];
|
||||||
const IMAGE_EXTENSIONS = [ ...IMAGE_EXTENSIONS_VIEWABLE, 'svg' ];
|
const IMAGE_EXTENSIONS = [ ...IMAGE_EXTENSIONS_VIEWABLE ];
|
||||||
|
|
||||||
class MediaLibrary extends React.Component {
|
class MediaLibrary extends React.Component {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user