writemonkey / wm3

165 stars 5 forks source link

Some problems with images #379

Closed tomasrei closed 4 years ago

tomasrei commented 4 years ago

Hi! Some issues with images it seems like.

First, if you paste online jpg address in the repository it just displays a blank snippet. If you drag it to the document it inserts the proper code+link. It doesn't display in the preview panel - but is displayed if I use "open in browser".

Secondly, if I use a file-path on my hard drive - it just adds the text without conversion, meaning that if I add the following address to the repository it displays the address as is: C:\Users\username\Documents\Statsvetenskap II\Perspektiv på politik HT20\Studielitteratur\hall_taylor.jpg becomes:

C:\Users\username\Documents\Statsvetenskap II\Perspektiv på politik HT20\Studielitteratur\hall_taylor.jpg

Finally, the above address won't work but if I put it on my desktop or my microSD for example. Like this is ok:

![image text](C:/Users/username/Desktop/hall_taylor.jpg)

this also works (D is microSD-drive):

![image text](D:/hall_taylor.jpg)

but not this:

![image text](C:/Users/username/Documents/Statsvetenskap II/Perspektiv på politik HT20/Studielitteratur/hall_taylor.jpg)

Maybe it something to do with permissions?

writemonkey commented 4 years ago

Hi, replace spaces in paths with %20. So this should work:

C:\Users\username\Documents\Statsvetenskap%20II\Perspektiv%20på%20politik%20HT20\Studielitteratur\hall_taylor.jpg

i.

writemonkey commented 4 years ago

You can also use repository macro below to replace spaces with %20 in selected text - i.e. URLs:

/* Replace spaces with %20 */
var e = _editor;
var m = wm;

function r(t) {
    t = t.replace(/ /g, "%20");
    return t;
}

if (e.somethingSelected()) {
    var t = r(e.getSelection());
    e.replaceSelection(t, "around");
} else {
    m.showNotice("Nothing selected!");;
}