From The Smartest Wiki
Jump to: navigation, search

SmartestAsset is the base class for all assets, or 'files' in Smartest's Media library, as well as user profile pictures, site logos, and page thumbnail images. It is a huge class, and comprises a lot of different functionality to support the creation, modification, organisation and deletion of assets.

Assets contained in instances of this class may be one of the asset type described in System/Core/Types/assettypes.yml.

This class is extended by SmartestRenderableAsset, which is used for any assets that are to be rendered on any web page.


  • text OR text_content - returns the text content of the asset (where applicable)
  • description OR caption
  • text_fragment
  • type_info - returns the asset type as an array
  • type - returns the asset type code
  • label - returns the label of the asset. Its title.
  • default_parameters - the default values of the asset type's parameters, if any, as an array.
  • full_path - the file path on disk for the file, if it is not stored in the database.
  • absolute_uri OR absolute_url - the full url for the file, including protocol and fully qualified host name.
  • storage_location - the folder where the file is stored, if stored on disk.
  • is_external - is the file externally hosted
  • web_path - the section of the file's URL after (but including) the domain.
  • bg_css - if the asset is an image, renders as a CSS background-image declaration, e.g. background-image:url('/Resources/Images/example.jpg')
  • size - returns the file size as a formatted string, for instance "10.4 MB".
  • raw_size OR size_raw - returns the file size in bytes of the file as an integer.
  • modified
  • owner - returns the owner of the file as a SmartestSystemUser object.
  • is_image - returns a boolean true if the image is a JPEG, GIF, PNG or SVG file. Otherwise boolean false.
  • is_binary_image - returns a boolean true if the image is a JPEG, GIF, or PNG file. Otherwise boolean false.