Insert image in rich text field

183 views
Skip to first unread message

pedr...@gmail.com

unread,
Aug 3, 2022, 8:58:58 AM8/3/22
to mementodatabase
Hello. In order to create a custom report inside a Rich Text field. I'm triyng to insert local images.
I did it many years ago. But now I can't remember how I did it.
For example...
  I have a rich text field named: Display
  I have a text field named: txt
  I coded a simple Action script:

let txt = entry().field("txt");
entry().set("Display", txt);

When I execute the script with a value for txt field like:
Using an external image. I have no problem. The image of the koala was inserted correctly inside the Display field
But if I try to insert a local image stored in my device...
    <img src = "file:///storage/emulated/0/MyImages/image01.jpg"/>
  Nothing was inserted in the Display (Rich Text field) when I executed the Action script

Thanks in advance for your help




Bill Crews

unread,
Aug 3, 2022, 2:10:37 PM8/3/22
to pedr...@gmail.com, mementodatabase
Try replacing "https" with "file".

--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/e69caa70-0ee0-4cf7-8ed9-92eb390c0becn%40googlegroups.com.

Er Mo

unread,
Aug 3, 2022, 2:47:00 PM8/3/22
to mementodatabase
Hallo
Es könnte auch an Android 12 und deren Sicherheits konzept ligen . Können sie das Bild von einen Anderen Programm aus öffnen , wenn die  Adresse verwenden .

Hi
It could also be due to Android 12 and its security concept. Can you open the image from another program using the address .

Ernst

pedr...@gmail.com

unread,
Aug 4, 2022, 2:45:31 AM8/4/22
to mementodatabase
Thank you for the quick response. But yes, I had already tried replacing http:// for file:///. And it still doesn't work

JMRuas

unread,
Aug 4, 2022, 7:01:32 AM8/4/22
to pedr...@gmail.com, mementodatabase
Hi,

I get a different location from an image in my phone.

file:///data/user/0/com.luckydroid.droidbase/files/files/-62970437/Screenshot.jpg

To get the URL I create an image field and I export to CSV. Then I get the URL found in the CSV file.

Can it solve the problem? 

pedr...@gmail.com

unread,
Aug 5, 2022, 3:15:59 PM8/5/22
to mementodatabase
Thanks JMRuas but no. It can't

/data/user/0/com.luckydroid.droidbase/files/files/-62970437/Screenshot.jpg is the location for internal storage, and it should be independent of the internal or external storage like:
    - /storage/0/myFolder/image.jpg for external primary storage
    - /storage/3467-3123/myFolder/image.jpg for external secondary storage
   
I'm getting crazy because years ago I did it after a conversation: https://groups.google.com/g/mementodatabase/c/r6ucEvrM8pI/m/AClzB_EkDQAJ in which Eugene Kartoyev spoke about the possibilities of the Rich Text field.
The bad side is that I can't remember how to do it.
I'm able to insert the image in the Rich Text field through a script if the image is stored on the internet. Putting this in the text field:

<img src="https://external-site/images/image.jpg" />

I'm also able to insert the image in the Rich Text field, converting the image to base64 like...

<img src="data:image/jpg;base64,TheImageCodedAsTextInBase64" />

I think the problem may be in the scheme part or something. Furthermore, I really don't have a clue why <img src="file:///storage/emulated/0/images/image.jpg" /> don't render the image in the Rich Text field

Thanks

Bill Crews

unread,
Aug 6, 2022, 4:37:40 AM8/6/22
to pedr...@gmail.com, mementodatabase
Need I point out that your...

/data/user/0/com.luckydroid.droidbase/files/files/-62970437/Screenshot.jpg

...is the same as JMRuss's with the"file://" removed? I don't do photos or even files on Memento, but y'all that do need to get a common understanding of what formats of file pathnames work and all of you use that format from then on.

The "file://" turns a local pathname into an Internet URL. Maybe the wiki should document more of these things in Trigger Examples, in Memento JavaScript Library under the File object & maybe the Http object, & any other place people might try to look up a solution to this kind of problem.

And I don't know if the pathname of a file is the same on every platform or not. I guess I'm doubting it, so people shouldn't post forum questions without announcing the pertinent platform (not just edition) along with the Memento release & whether or not you're using the beta version rather than the production version.

I don't think Help > Help > About tells whether you're in beta or not. If not, the developer should add this to the About to keep people from having to remember or dig through emails or browser history from around the date Memento was last installed to find out.

It's amazing how many forum questions come from the area around photos, files, and barcodes & QR codes, whether it's in syncing them, backing them up, moving them to a new device, or just finding them in the first place. And also security surrounding them. Maybe a whole new section of the wiki could document all this stuff in one place.
_________

Muss ich darauf hinweisen, dass Ihr...

/data/user/0/com.luckydroid.droidbase/files/files/-62970437/Screenshot.jpg

... ist das gleiche wie bei JMRuss, wobei "file://" entfernt wurde?  Ich mache keine Fotos oder gar Dateien auf Memento, aber Sie alle müssen sich ein gemeinsames Verständnis darüber verschaffen, welche Formate von Dateipfadnamen funktionieren, und Sie alle verwenden dieses Format von da an.

Das "file://" verwandelt einen lokalen Pfadnamen in eine Internet-URL.  Vielleicht sollte das Wiki mehr davon in Trigger-Beispielen, in der Memento-JavaScript-Bibliothek unter dem File-Objekt und vielleicht dem Http-Objekt und an jedem anderen Ort dokumentieren, an dem Leute versuchen könnten, eine Lösung für diese Art von Problem zu finden.

Und ich weiß nicht, ob der Pfadname einer Datei auf jeder Plattform gleich ist oder nicht.  Ich glaube, ich bezweifle es, also sollten die Leute keine Forumsfragen stellen, ohne die relevante Plattform (nicht nur die Edition) zusammen mit der Memento-Veröffentlichung anzukündigen und ob Sie die Beta-Version anstelle der Produktionsversion verwenden oder nicht.

Ich glaube nicht, dass Hilfe > Hilfe > Info sagt, ob Sie in der Beta sind oder nicht.  Wenn nicht, sollte der Entwickler dies zur Info hinzufügen, um zu verhindern, dass sich die Leute E-Mails oder den Browserverlauf von ungefähr dem Datum, an dem Memento zuletzt installiert wurde, merken oder durchsuchen müssen, um dies herauszufinden.

Es ist erstaunlich, wie viele Forenfragen aus dem Bereich um Fotos, Dateien und Barcodes & QR-Codes kommen, sei es beim Synchronisieren, Sichern, Verschieben auf ein neues Gerät oder beim Finden.  Und auch die Sicherheit, die sie umgibt.  Vielleicht könnte ein ganz neuer Abschnitt des Wikis all diese Dinge an einem Ort dokumentieren.


Reply all
Reply to author
Forward
0 new messages