You are here

function img_assist_get_macros in Image Assist 5.2

Same name and namespace in other branches
  1. 5.3 img_assist.module \img_assist_get_macros()
  2. 5 img_assist.module \img_assist_get_macros()
  3. 6.2 img_assist.module \img_assist_get_macros()
  4. 6 img_assist.module \img_assist_get_macros()

Return all img_assist macros as an array.

Related topics

2 calls to img_assist_get_macros()
img_assist_filter in ./img_assist.module
Implementation of hook_filter().
img_assist_map_save in ./img_assist.module
Update the map table

File

./img_assist.module, line 1636
Image Assist module

Code

function img_assist_get_macros($text) {
  $m = array();
  preg_match_all('/ \\[ ( [^\\[\\]]+ )* \\] /x', $text, $matches);

  // Don't process duplicates.
  $tag_match = (array) array_unique($matches[1]);
  foreach ($tag_match as $macro) {
    $current_macro = '[' . $macro . ']';
    $param = array_map('trim', explode('|', $macro));

    // The first macro param is assumed to be the function name.
    $func_name = array_shift($param);
    if ($func_name == 'img_assist') {
      $vars = array();
      foreach ($param as $p) {
        $pos = strpos($p, '=');
        $varname = trim(substr($p, 0, $pos));
        $varvalue = substr($p, $pos + 1);
        $vars[$varname] = trim($varvalue);
      }

      // The full unaltered filter string is the key for the array of filter
      // attributes.
      $m[$current_macro] = $vars;
    }
  }
  return $m;
}