Provider.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Preview;
  8. use OCP\Preview\IProvider;
  9. abstract class Provider implements IProvider {
  10. private $options;
  11. /**
  12. * Constructor
  13. *
  14. * @param array $options
  15. */
  16. public function __construct(array $options = []) {
  17. $this->options = $options;
  18. }
  19. /**
  20. * @return string Regex with the mimetypes that are supported by this provider
  21. */
  22. abstract public function getMimeType();
  23. /**
  24. * Check if a preview can be generated for $path
  25. *
  26. * @param \OCP\Files\FileInfo $file
  27. * @return bool
  28. */
  29. public function isAvailable(\OCP\Files\FileInfo $file) {
  30. return true;
  31. }
  32. /**
  33. * Generates thumbnail which fits in $maxX and $maxY and keeps the aspect ratio, for file at path $path
  34. *
  35. * @param string $path Path of file
  36. * @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
  37. * @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
  38. * @param bool $scalingup Disable/Enable upscaling of previews
  39. * @param \OC\Files\View $fileview fileview object of user folder
  40. * @return bool|\OCP\IImage false if no preview was generated
  41. */
  42. abstract public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview);
  43. }