diff options
author | Max <max@nextcloud.com> | 2022-03-01 15:39:43 +0300 |
---|---|---|
committer | Max <max@nextcloud.com> | 2022-03-01 15:39:43 +0300 |
commit | f41546c94079eca609f2b0ae1d88c33d068f1efe (patch) | |
tree | 545108006aa2fd01230e305468afbe278710862f /src | |
parent | 2622a0066d56d696f403e849b93c24007cee54b4 (diff) | |
parent | 67788c856904bb8009a041d652bac09aa4664e04 (diff) |
Merge branch 'fix/stable23/image_data_urls' of https://github.com/DerpgonCz/text into DerpgonCz-fix/stable23/image_data_urls
Diffstat (limited to 'src')
-rw-r--r-- | src/nodes/ImageView.vue | 7 | ||||
-rw-r--r-- | src/tests/nodes/ImageView.spec.js | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/nodes/ImageView.vue b/src/nodes/ImageView.vue index df8f58b60..f39fb80ae 100644 --- a/src/nodes/ImageView.vue +++ b/src/nodes/ImageView.vue @@ -116,7 +116,7 @@ export default { } }, imageUrl() { - if (this.isRemoteUrl || this.isPreviewUrl) { + if (this.isRemoteUrl || this.isPreviewUrl || this.isDataUrl) { return this.src } if (this.hasPreview && this.mime !== 'image/gif') { @@ -132,6 +132,9 @@ export default { return this.src.match(/^(\/index.php)?\/core\/preview/) || this.src.match(/^(\/index.php)?\/apps\/files_sharing\/publicpreview\//) }, + isDataUrl() { + return this.src.startsWith('data:') + }, basename() { return decodeURI(this.src.split('?')[0]) }, @@ -218,7 +221,6 @@ export default { return } const img = new Image() - img.src = this.imageUrl img.onload = () => { this.imageLoaded = true } @@ -227,6 +229,7 @@ export default { this.imageLoaded = false this.loaded = true } + img.src = this.imageUrl }, methods: { updateAlt() { diff --git a/src/tests/nodes/ImageView.spec.js b/src/tests/nodes/ImageView.spec.js index 13a0b2456..51a8e0747 100644 --- a/src/tests/nodes/ImageView.spec.js +++ b/src/tests/nodes/ImageView.spec.js @@ -64,4 +64,10 @@ describe('Image View src attribute based on markdown', () => { expect(wrapper.find('.image__main').attributes('src')) .toBe('https://nextcloud/index.php/apps/files_sharing/publicpreview/CSYoWifBzrsMWeA?file=/deck11-calendar.png&x=1760&y=990&a=true') }) + + test('data urls are used as is', () => { + const src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=' + const wrapper = factory({src}) + expect(wrapper.find('.image__main').attributes('src')).toBe(src) + }) }) |