Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Icon.GetIconWithQuickLook

Queries the Finder icon for the file or folder with the given path.

Component Version macOS Windows Linux Server iOS SDK
QuickLook Files 2.3 ✅ Yes ✅ Yes ❌ No ✅ Yes, on macOS and Windows ❌ No
MBS( "Icon.GetIconWithQuickLook"; Path; Size { ; Flags } )   More

Parameters

Parameter Description Example Flags
Path The path to the file or folder. "/Applications"
Size The size of the icon picture you'd like to have. Suggested range is from 16 to 512 pixel. 512
Flags Available in MBS FileMaker Plugin 13.2 or newer.
Various flags.
Pass 1 to not frame quicklook previews.
Pass 2 to not return an icon, if quicklook is not available.
Pass 3 to use both flags.
0 Optional

Result

Container value.

Description

Queries the Finder icon for the file or folder with the given path.
This method tries first to get QuickLook preview for the file, before it tries the icon. QuickLook requires macOS 10.5. Size specifies the icon size from 16 to 512 pixel. The container value returned includes PNG data with alpha, JPEG preview, filename and size.

Version 4.3 adds support for Windows. We now query same thumbnail as explorer uses.
See also Icon.GetIcon.

Does not work on server due to missing quicklook services without an user account.

This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.

Examples

Queries preview on iPhoto app:

MBS( "Icon.GetIconWithQuickLook"; "/Applications/iPhoto.app"; 512 )

Add picture to field:

Set Field [ test::pic ; MBS("Icon.GetIconWithQuickLook"; "/Users/cs/Desktop/solar-system.png"; 512) ]

Make preview via QuickLook:

# try quickLook functions
Set Variable [ $fpath ; Value: GetAsText($input) ]
If [ Position ( $fpath ; "/" ; 1 ; 1 ) > 0 ]
    Set Variable [ $path ; Value: MBS( "Path.FileMakerPathToNativePath"; $fpath) ]
    If [ Length ( $path ) > 0 ]
        Set Variable [ $image ; Value: MBS( "Icon.GetIconWithQuickLook"; $path; 512; 1 ) ]
        If [ MBS("IsError") = 0 ]
            Set Field [ Get Preview::Preview ; $image ]
            Set Field [ Get Preview::Made using ; "QuickLook File" ]
            Exit Script [ Text Result: ]
        End If
    End If
Else If [ Position ( $types ; "FNAM" ; 1 ; 1 ) > 0 ]
    # write temp file
    Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; MBS( "Folders.UserTemporary" ); $fpath) ]
    Set Variable [ $r ; Value: MBS("Container.WriteFile"; $input; $path) ]
    If [ MBS("IsError") = 0 ]
        Set Variable [ $image ; Value: MBS( "Icon.GetIconWithQuickLook"; $path; 512; 1 ) ]
        If [ MBS("IsError") = 0 ]
            Set Field [ Get Preview::Preview ; $image ]
            Set Field [ Get Preview::Made using ; "QuickLook Container" ]
            Set Variable [ $r ; Value: MBS("Files.Delete"; $path) ]
            Exit Script [ Text Result: ]
        End If
        Set Variable [ $r ; Value: MBS("Files.Delete"; $path) ]
    End If
End If

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 15th April 2023


Icon.GetIcon - Icon.SetIcon