You are here

public static function QueryPath::encodeDataURL in QueryPath 7.2

Same name and namespace in other branches
  1. 6 QueryPath/QueryPath.php \QueryPath::encodeDataURL()
  2. 7.3 QueryPath/QueryPath.php \QueryPath::encodeDataURL()
1 call to QueryPath::encodeDataURL()
QueryPath::dataURL in QueryPath/QueryPath.php

File

QueryPath/QueryPath.php, line 183

Class

QueryPath

Code

public static function encodeDataURL($data, $mime = 'application/octet-stream', $context = NULL) {
  if (is_resource($data)) {
    $data = stream_get_contents($data);
  }
  elseif (filter_var($data, FILTER_VALIDATE_URL)) {
    $data = file_get_contents($data, FALSE, $context);
  }
  $encoded = base64_encode($data);
  return 'data:' . $mime . ';base64,' . $encoded;
}