embed image in the mail

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

embed image in the mail

guiraud.sabrina
Hi, I'm looking for an example code to embed images that I Have in my extension (depending of what the user is typing)

how do you load an image from extension package, for webextension in FF there is :
chrome.extension.getURL("images/my-image.png"); what is the api for TB ?

and once you have your file url (here an image) how do you embed it in the mail?

thx
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: embed image in the mail

Jörg Knobloch
On 15/02/2018 22:31, [hidden email] wrote:
> and once you have your file url (here an image) how do you embed it in the mail?

File-based images need to be converted to data: URLs. Some existing
add-ons do this already, for example "Signature Switch".

You can find the code to copy/adapt here:

https://dxr.mozilla.org/comm-central/rev/87cad73c874af0a169ba3ecf9118b318b62af1a5/mail/components/compose/content/MsgComposeCommands.js#6832

Or if you have an overlay of the compose window, you could try calling
it directly.

Jörg.

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: embed image in the mail

guiraud.sabrina
In reply to this post by guiraud.sabrina
nice and say I have my images in chrome/content/images

what would be the url I set for one image in

loadBlockedImage(aURL

thx

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: embed image in the mail

Jörg Knobloch
On 15/02/2018 23:21, [hidden email] wrote:
> nice and say I have my images in chrome/content/images
>
> what would be the url I set for one image in
>
> loadBlockedImage(aURL

That should work, too, we do it here:

https://dxr.mozilla.org/comm-central/rev/87cad73c874af0a169ba3ecf9118b318b62af1a5/mail/components/compose/content/cloudAttachmentLinkManager.js#406

Jörg.

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: embed image in the mail

guiraud.sabrina
In reply to this post by guiraud.sabrina
indeed 'chrome://asciidoctor_tb/content/images/tag.png' works

I've refered in my script the MsgComposeCommands.js:

ChromeUtils.import("resource:///modules/MsgComposeCommands.js");

then I call it in my script:

console.log(loadBlockedImage('chrome://asciidoctor_tb/content/images/tag.png',true));

then I can see the correct data url!
I've seen that the function can swap the url with the data in the mail composer, I'll do some tests

thx a lot
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: embed image in the mail

guiraud.sabrina
well finally I've extracted the method loadBlockedImage

because when importing all MsgComposeCommands.js

My observer on the compose windows were disabled, do not understand why, here are  my observers/listeners:

https://jsfiddle.net/0k92vapL/
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird