You are here

function file_style_load in Styles 7

Load a style by style name or ID. May be used as a loader for menu items.

Parameters

$name: The name of the style.

$isid: Optional. The numeric id of a style if the name is not known.

$include: If set, this loader will restrict to a specific type of file style, may be one of the defined Image style storage constants.

Return value

An image style array containing the following keys:

  • "msid": The unique file style ID.
  • "name": The unique file style name.
  • "effects": An array of file effects within this file style.

If the file style name or ID is not valid, an empty array is returned.

See also

file_effect_load()

File

contrib/file_styles/file_styles.module, line 571
File widget formatter definitions.

Code

function file_style_load($name = NULL, $isid = NULL, $include = NULL) {
  $styles = file_styles();

  // If retrieving by name.
  if (isset($name) && isset($styles[$name])) {
    $style = $styles[$name];
  }

  // If retrieving by file style id.
  if (!isset($name) && isset($isid)) {
    foreach ($styles as $name => $database_style) {
      if (isset($database_style['msid']) && $database_style['msid'] == $isid) {
        break;
      }
    }
  }

  // Restrict to the specific type of flag. This bitwise operation basically
  // states "if the storage is X, then allow".
  if (isset($style) && (!isset($include) || $style['storage'] & (int) $include)) {
    return $style;
  }

  // Otherwise the style was not found.
  return FALSE;
}