}
if (stripos($source, '.svg') !== false) {
- $source = $this->_fixSVG($source);
+ $source = \Cubist\Util\Graphics\Image::fixSVGDimensions($source);
}
$this->vdir->copy($source, $dest);
}
- protected function _fixSVG($source) {
- $fixed = str_replace('.svg', '.f.svg', $source);
- if (file_exists($fixed) && filemtime($fixed) >= filemtime($source)) {
- return $fixed;
- }
- $svg = simplexml_load_string(file_get_contents($source));
- $attr = $svg->attributes();
- if (isset($attr['width'], $attr['height'])) {
- copy($source, $fixed);
- return $fixed;
- }
-
- $dim = Image::getimagesize($source);
- $svg->addAttribute('preserveAspectRatio', 'none');
- $svg->addAttribute('width', $dim[0]);
- $svg->addAttribute('height', $dim[1]);
- file_put_contents($fixed, $svg->asXML());
-
- return $fixed;
- }
-
public function getVideosFormats() {
return ['mp4', 'jpg'];
}