Fix '#' not working in image paths in UI

Fixes #733
This commit is contained in:
JannisX11 2020-11-07 20:48:58 +01:00
parent df0dbe4425
commit 629c118856
6 changed files with 9 additions and 9 deletions

View File

@ -112,7 +112,7 @@ window.BedrockEntityManager = {
}
}).show()
$('#import_texture_list li').each((i, el) => {
$(el).css('background-image', `url("${ valid_textures_list[i].replace(/\\/g, '/') }?${Math.round(Math.random()*1e6)}")`)
$(el).css('background-image', `url("${ valid_textures_list[i].replace(/\\/g, '/').replace(/#/g, '%23') }?${Math.round(Math.random()*1e6)}")`)
.click(function() {
if (selected_textures.includes(i)) {
selected_textures.remove(i)

View File

@ -426,7 +426,7 @@ var Extruder = {
showDialog('image_extruder')
Extruder.ext_img = new Image()
Extruder.ext_img.src = isApp ? file.path : file.content
Extruder.ext_img.src = isApp ? file.path.replace(/#/g, '%23') : file.content
Extruder.image_file = file
Extruder.ext_img.style.imageRendering = 'pixelated'
ctx.imageSmoothingEnabled = false;

View File

@ -852,8 +852,8 @@ class Preview {
this.getBackground()
if (this.background && this.background.image) {
if (!this.background.imgtag) this.background.imgtag = new Image();
this.background.imgtag.src = this.background.image;
$(this.canvas).css('background-image', 'url("'+this.background.image.split('\\').join('/')+'")')
this.background.imgtag.src = this.background.image.replace(/#/g, '%23');
$(this.canvas).css('background-image', `url("${this.background.image.replace(/\\/g, '/').replace(/#/g, '%23')}")`)
} else {
$(this.canvas).css('background-image', 'none')
}

View File

@ -213,8 +213,8 @@ Interface.definePanels(() => {
if (extension == 'png') {
var img = new Image(file.content);
img.src = file.content || file.path;
var img = new Image();
img.src = file.content || file.path.replace(/#/g, '%23');
img.onload = function() {
var c = document.createElement('canvas');
var ctx = c.getContext('2d');

View File

@ -190,7 +190,7 @@ class Texture {
if (this.mode === 'bitmap') {
Merge.string(this, data, 'source')
} else if (data.path) {
this.source = this.path + '?' + tex_version;
this.source = this.path.replace(/#/g, '%23') + '?' + tex_version;
}
return this;
}
@ -277,7 +277,7 @@ class Texture {
if (path.includes('data:image')) {
this.source = path
} else {
this.source = path + '?' + tex_version
this.source = path.replace(/#/g, '%23') + '?' + tex_version
}
this.generateFolder(path)
this.startWatcher()

View File

@ -32,7 +32,7 @@ class CanvasFrame {
}
async loadFromURL(url) {
let img = new Image()
img.src = url;
img.src = url.replace(/#/g, '%23');
await new Promise((resolve, reject) => {
img.onload = () => {
this.loadFromImage(img);