Changeset View
Changeset View
Standalone View
Standalone View
src/applications/celerity/CelerityResourceTransformer.php
Context not available. | |||||
// Some resources won't survive minification (like d3.min.js), and are | // Some resources won't survive minification (like d3.min.js), and are | ||||
// marked so as not to be minified. | // marked so as not to be minified. | ||||
if (strpos($data, '@'.'do-not-minify') !== false) { | if (@strpos($data, '@'.'do-not-minify') !== false) { | ||||
return $data; | return $data; | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
public static function getResourceType($path) { | public static function getResourceType($path) { | ||||
return last(explode('.', $path)); | return last(@explode('.', $path)); | ||||
} | } | ||||
public function translateResourceURI(array $matches) { | public function translateResourceURI(array $matches) { | ||||
Context not available. | |||||
* @return string|null Data URI, or null if we declined to generate one. | * @return string|null Data URI, or null if we declined to generate one. | ||||
*/ | */ | ||||
private function generateDataURI($resource_name) { | private function generateDataURI($resource_name) { | ||||
$ext = last(explode('.', $resource_name)); | $ext = last(@explode('.', $resource_name)); | ||||
switch ($ext) { | switch ($ext) { | ||||
case 'png': | case 'png': | ||||
$type = 'image/png'; | $type = 'image/png'; | ||||
Context not available. | |||||
$maximum_data_size = (1024 * 32); | $maximum_data_size = (1024 * 32); | ||||
$data = $this->celerityMap->getResourceDataForName($resource_name); | $data = $this->celerityMap->getResourceDataForName($resource_name); | ||||
if (strlen($data) >= $maximum_data_size) { | if (@strlen($data) >= $maximum_data_size) { | ||||
// If the data is already too large on its own, just bail before | // If the data is already too large on its own, just bail before | ||||
// encoding it. | // encoding it. | ||||
return null; | return null; | ||||
} | } | ||||
$uri = 'data:'.$type.';base64,'.base64_encode($data); | $uri = 'data:'.$type.';base64,'.base64_encode($data); | ||||
if (strlen($uri) >= $maximum_data_size) { | if (@strlen($uri) >= $maximum_data_size) { | ||||
return null; | return null; | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0