You are here

private function SassExtentionsCompassFunctionsInlineData::compute_mime_type in Sassy 7

2 calls to SassExtentionsCompassFunctionsInlineData::compute_mime_type()
SassExtentionsCompassFunctionsInlineData::inline_font_files in phamlp/sass/extensions/compass/functions/inlineData.php
SassExtentionsCompassFunctionsInlineData::inline_image in phamlp/sass/extensions/compass/functions/inlineData.php

File

phamlp/sass/extensions/compass/functions/inlineData.php, line 42

Class

SassExtentionsCompassFunctionsInlineData
Compass extension SassScript inline data functions class. A collection of functions for use in SassSCript. @package PHamlP @subpackage Sass.extensions.compass.functions

Code

private function compute_mime_type($path, $mime_type = null) {
  if ($mime_type) {
    return $mime_type;
  }
  switch (true) {
    case preg_match('/\\.png$/i', $path):
      return 'image/png';
      break;
    case preg_match('/\\.jpe?g$/i', $path):
      return 'image/jpeg';
      break;
    case preg_match('/\\.gif$/i', $path):
      return 'image/gif';
      break;
    case preg_match('/\\.otf$/i', $path):
      return 'font/opentype';
      break;
    case preg_match('/\\.ttf$/i', $path):
      return 'font/truetype';
      break;
    case preg_match(' /\\.woff$/i', $path):
      return 'font/woff';
      break;
    case preg_match(' /\\.off$/i', $path):
      return 'font/openfont';
      break;
    case preg_match('/\\.([a-zA-Z]+)$/i', $path, $matches):
      return 'image/' . strtolower($matches[1]);
      break;
    default:
      throw new SassScriptFunctionException('Unable to determine mime type for {what}, please specify one explicitly', array(
        '{what}' => $path,
      ), SassScriptParser::$context->node);
      break;
  }
}