Thank you for your post.
At this time, a function to determine a Container file type is not available. Although there are certain attributes that apply to specific Container field types, one option is to use the "filename" attribute, as this will extract the file name including the extension. You can then parse out the file extension to determine the file type.
I recommend entering this as a suggestion into our Feature Requests web form at:
The entries into this web form populate a database file hosted by Product Management and Development. All entries are read, discussed and considered for possible implementation in a future release. Although I could copy your post and paste it into the web form, there are a couple of questions asked on the form that only you can answer.
I used this calculation in a non-stored calculation field and It displays "Other" Or "Picture". I only tested a couple of items that test correctly.
This worked on a desktop when the images was inserted as a picture, if the image was inserted as a file it will display "Other". I will have to test on an ipad and let you know.
I tested on an iPad and camera, signature, photos, and PDF insert by Files all return a width so the calculation would display "Picture", so this would not tell you what items is in the container.
If(GetContainerAttribute(Media;"width")="?";"Other";"Picture") does appear to work almost correctly in FMGo
I should have just tried this. Did not imagine, for some reason, that ? was the literal response.
Since I am using this to scale an image, it is OK for camera, photo and signature but you are correct
that PDF also returns a width, so it remains an issue. I wonder if there is another characteristic like width
that would differentiate PDF uniquely. I suppose as TSGal suggests I could look for .pdf in the file name since it is definitely a file reference.
Your more complete approach is good but simple is better where possible.
No width returned for audio and the other files I tested files? Wonder if files other than .pdf have a width?
thank you S Chamblee
TSGal: I have submitted a feature request as you have suggested.
parsing filename extensions is a nice suggestion but I wonder if they are there if I take an image on the camera, for instance, and embed it into the database rather than referencing it externally.
If you take a picture with the camera, the picture will be embedded in the database, and the extension will be .jpg.
For example, I just hosted a database file in FileMaker Pro, accessed the file via FileMaker Go, tapped into the Container field and took a picture. The GetContainerAttribute(Media ; "filename") resulted in "Photo 08-12-2014 14.51.30.jpg"
I created a sample app that will detect if the items is a photo, video, signature, pdf or just about any file type if you modify the calculation. It's is easier to post a sample then copying and pasting the calculations. I have 3 calculation fields in the sample, but only two are required, which it could be done in one, but for readability I use separate calculation fields. Take a look at the calculations.
Here is the link again. https://www.dropbox.com/s/yhnmst2bjrwu1sj/TestContainer.fmp12?dl=0
I used GetContainerAttribute(Media;"All") in my sample then used patterncount to detect Photo in the filename for photos. The filename contains the type, and as TSGal stated the file extension can be used also, which is also used in my sample app. I do believe all the information is in the "filename", so you could use "Filename" instead of "all". It display "Video" in the filename for quicktime, so I used the file extension to detect quicktime.
Good demo S Chamblee : )
// To identify images in containers
If ( PatternCount ( GetContainerAttribute ( Media;"filename" ) ; ".jpg" ) or
PatternCount ( GetContainerAttribute ( Media;"filename" ) ; ".png" ) or
PatternCount ( GetContainerAttribute ( Media;"filename" ) ; ".bmp" ) or
PatternCount ( GetContainerAttribute ( Media;"filename" ) ; ".gif" ) or
PatternCount ( GetContainerAttribute ( Media;"filename" ) ; ".tif" )
; "Image"; "Not Image"