You are here

function media_parse_css_declarations in D7 Media 7

Parses the contents of a CSS declaration block and returns a keyed array of property names and values.

Parameters

$declarations: One or more CSS declarations delimited by a semicolon. The same as a CSS declaration block (see http://www.w3.org/TR/CSS21/syndata.html#rule-sets), but without the opening and closing curly braces. Also the same as the value of an inline HTML style attribute.

Return value

A keyed array. The keys are CSS property names, and the values are CSS property values.

1 call to media_parse_css_declarations()
media_token_to_markup in includes/media.filter.inc
Replace callback to convert a media file tag into HTML markup.

File

includes/media.filter.inc, line 308
Functions related to the WYSIWYG editor and the media input filter.

Code

function media_parse_css_declarations($declarations) {
  $properties = array();
  foreach (array_map('trim', explode(";", $declarations)) as $declaration) {
    if ($declaration != '') {
      list($name, $value) = array_map('trim', explode(':', $declaration, 2));
      $properties[strtolower($name)] = $value;
    }
  }
  return $properties;
}