* introduces a method in OC_Image which doesn't stretch images when trying to make them fit in a box
* adds the method to all key providers so that they can do their job, as expected by the Preview class
* improves the caching mechanism of Preview in order to reduce I/O and to avoid filling the available disk space
* fixes some long standing issues
* **contains mostly tests**
The first time we're asked to generate a preview we'll generate one of the maximum dimension indicated in the configuration and all future resizing requests will be done on that preview in order to not waste time converting the same file over and over.
One of the fixes required for #12465
`$this->info` can very well contain an empty array or possibly other values. This means that when this code path is called a PHP Fatal error might get thrown which is not what we want.
FIXME: Ugly hack to prevent SVG of being returned if the SVG
provider is not enabled.
This is required because the preview system is designed in a
bad way and relies on opt-in with asterisks (i.e. image/*)
which will lead to the fact that a SVG will also match the image
provider.
Conflicts:
lib/private/preview.php
The "*/*" provider has been removed. This is therefore not needed anymore and leads to unexpected bugs.
Please notice that this is only relevant for master.
This function is also used in a way such as:
```
$preview = new \OC\Preview(\OC_User::getUser(), 'files');
$info = \OC\Files\Filesystem::getFileInfo($file);
if (!$always and !$preview->isAvailable($info)) {
\OC_Response::setStatus(404);
} else {
$preview->setFile($file);
$preview->setMaxX($maxX);
$preview->setMaxY($maxY);
$preview->setScalingUp($scalingUp);
$preview->setKeepAspect($keepAspect);
}
```
Which won't work anymore since `setFile` is used instead of passing the file in the constructor. Fixes a regression in master.
- adding keep aspect to core/ajax/preview.php
- remove duplicate method Preview::show()
- no more hard coded mimetype of preview
- remove .png from the preview urls
- keep old route preview.png for backwards compatibility
- aspect preserving previews are now cached