It might not help because it’s in svelte and it doesn’t look like you’re using
lemmy-js-client
, but this is an example of how I do it in Alexandrite usinglemmy-js-client
. TheonPaste
function handles thepaste
event on the markdown editor textarea when someone pastes with an image in their clipboard, and theonFileInputChange
is thechange
event for an<input type="file" />
element so when someone selects a file it uploads and the input’s label can be styled like a button. Here is the client’s fetch function which handles the authorization header and whatnot. You can upload client-side without a proxy server for any instance running a newer version of Lemmy than like… 0.19.0? I didn’t want to be responsible for proxying image uploads so I waited to add image uploading in Alexandrite until I could do the uploads directly client side.