GetContainerAttribute() is a handy new function available in FileMaker 13. It allows us to get a lot of the metadata from files that we put into our containers, to assist with creating new, container focused features.
First off, lets review the function syntax:
GetContainerAttribute ( _name of container field here_ ; _name of attribute here_ )
Attributes
Attributes are the names of the metadata values that we can pull. The list of attributes available changes with the type of content places in a container field. So attributes for image attributes are not the same as barcode attributes. Note that you can enter an attribute value of all and return all available metadata on the container contents. Additionally, FileMaker has built-in attribute groups to allow you to pull attributes specific to a type of file. Lastly, note that a blank value is returned where there is no value for a requested attribute.
Listing of attribute groups and their available attributes
For a listing of all available attributes and attribute groups, visit the official FileMaker reference page. Not only does it cover the function, but it has detailed explanations of all of the attributes as well.
Specifically, get to know the following attribute groups: General
- Audio
- Image
- Photo
- Barcode
- Signature
- All
Calling one of these groups in the function will return all available attributes for that group. For example, if I request GetContainerAttribute(table::imagecontainer ; “Image”) it will return the attributes of width, height, dpiwidth, dpiheight and transparency. Note that this is if those attributes are available. If I tried to read the barcode group on an image, it wouldn’t return any attributes.
Why is this useful?
The metadata available now is extremely useful for dealing with container fields. FileMaker13 introduced native barcode capture in iOS, and a few other new container specific functions as well, especially geared towards iOS use. Previously, this metadata was only available with some creative hacks or plug-in usage, not natively. Developers using those hacks and plug-ins have already began leveraging the power of metadata into their solutions, making them not constrained by the native bounds of the container object.
Example use cases
A couple of use cases that we came up with where this metadata would be useful:
- Using the file size attributes to reject files that are too large for container fields
- Using image width/height attributes to show/hide different portrait/landscape container objects
- Using the latitude/longitude attributes to verify photos were taken in the area they were supposed to be captured
- Using the transparency attribute to find and export only images that are transparent
- Displaying ID3 tag info from stored MP3 and M4a files
- Creating custom icon sets for different kinds of documents
It’s easy to see why this new function is a great addition to the ability of the container field type! We’ve demonstrated a few uses of this function in our Get Container Attributes demo file. Caution, the file size is a bit large because we stuck some sample media files in there.
About the Author
Mike Beargie has been with MainSpring since 2013 and has over 10 years of application development experience. As a developer, he creates solutions for clients in a wide variety of sectors across the U.S. and abroad. Prior to working at MainSpring, Mike worked as the lead developer for a consulting company, serving high profile political, special interest and nonprofit clients in the Washington, D.C., and Columbus, Ohio, markets. Mike regularly presents solutions and best practices to the FileMaker development community around the country, and is well known as an answer man online as well. In 2014 and 2016, Mike was recognized with the FileMaker Excellence Award for community contributions. Mike is a man of many hobbies, including woodworking, home brewing, art and music.