Code Example of How to Attach a Photo to a Record

could someone please show me where to find a Code Example of How to Attach a Photo to a Record?
Thanks ~Jack

Here is the Panorama X documentation about Image Display Objects.

Basically you don’t save images in the database, you save paths to images in your database. It is comfortable to keep those images in (a subfolder of) the folder of your database, because then you can use simple relative paths.

I have a database which lists tools which I own. What I want to do is:

  1. Use have an input form where I enter the item description.
  2. Drag a jpg picture of it to a place on the form where it is programatically attached to the record.
    Utter simplicity but I don’t know how to do it.

Thanks for the Pan X object/image page which you referred. I spent over 2 hours searching for something like that.

Unfortunately there is no documentation on this topic at this time.

I think this would work:
You must have one or more database fields already, holding information on the tools. Add a field to hold the path to its jpg. On the form add a text editor object linked to that field. And an image display object set to display the current record of that field. You can set that with a ‘default’ imaging pointing to a generic picture saying ‘image needed’ or some such. Then, with the tool’s record showing, just drag and drop the image file into the text editor object. In principle that should put its path into the linked record field. May need some tweaking, but I’d suspect Help on TEOs and IDOs would get you by.

Create a text field named Images on your data sheet. On your form create a Drag Receiver Object the size of the image you want displayed with the path added to your Images field. In the Options panel set the Accepts: option to Files and the Extensions: to .jpg.png with no quotes or spaces between the extension names. In the Procedure panel of the Drag Receiver place this code: Image=catcherror("",info(“dropfiles”)).

Create an Image Display Object on top of the Drag Receiver and set it to the same size as the Drag Receiver. Set the Formula pane for this to simply Images. Now if you drag a file from the Finder onto the combination Image Display/Drag Receiver it will display the image at the same time as it is putting the image path into the Images field of the current record. The related image will now show for each record as you navigate through them.

DragImage

2 Likes

Drag Receiver Object, not yet documented by Jim nor noticed by me in the Object Library. Sounds better than my text editor suggestion. Perhaps it’s in the latest videos I’ve not yet found time (but will!) to watch.

Nope, as I mentioned earlier it’s not documented anywhere I don’t think. But Gary has described it accurately. Maybe I privately explained it to him at some point, or he may have reverse engineered it from a database I posted.

The drag receiver object will continue to work, but I do have some ideas for possibly enabling drops on other types of objects, which is one reason this isn’t documented yet.

I do have to question Gary’s taste in example images though!

No, this one was easy to figure out with the object’s name and the items in the Options panel. The hardest part was finding out the exact syntax for adding the extensions filter. I was given a clue, however, with the description of File Types in the dropfromfinder documentation. I have been using this method for some time now including in a few place on my current project.

You might be remembering a discussion we had way back when regarding the undocumented Elastic Zone object. I couldn’t figure out what it was for or how to use it and you told me it wasn’t fully implemented and may never be completed. I was getting all kinds of weird actions when experimenting with it.

1 Like

Gary has provided a perfect answer to the question how to attach a picture to a database record, but this is not the best method to attach a folder with a lot of pictures to a database.

Suppose your database has one field “Path”.

Panorama X can list the files contained in a folder (see the documentation of the filecatalog( function) and append the array of the found file paths to your database (see fileappend or importtext documentation. Then you only need a form with an Image Display object with the formula

Path

to display the images for all records.

1 Like

I want images associated with their own records ONLY. Might be multiple images per record but not multiple records per image. Simple minded example is a names list with an attached photo for each name.
Jack

Thanks Gary,
I will try, and let you know the result, when I have time.
Too bad it takes so much programming. I think this should be built as a feature object because it is so commonly used. Flexibility at all costs is not always good. It can be a pain to use. This ia IMHO.
Jack

I did not talk about multiple pictures per record.

I talked about a folder with let’s say 100 pictures, associated one by one to 100 records in your database.

Can I just point out that Gary’s suggestion involved ONE line of code?

Image=catcherror("",info(“dropfiles”))