UploadResizeConfig.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Backend\Model\Image;
  8. /**
  9. * Image uploader config provider.
  10. */
  11. class UploadResizeConfig implements UploadResizeConfigInterface
  12. {
  13. /**
  14. * Config path for the maximal image width value
  15. */
  16. const XML_PATH_MAX_WIDTH_IMAGE = 'system/upload_configuration/max_width';
  17. /**
  18. * Config path for the maximal image height value
  19. */
  20. const XML_PATH_MAX_HEIGHT_IMAGE = 'system/upload_configuration/max_height';
  21. /**
  22. * Config path for the maximal image height value
  23. */
  24. const XML_PATH_ENABLE_RESIZE = 'system/upload_configuration/enable_resize';
  25. /**
  26. * @var \Magento\Framework\App\Config\ScopeConfigInterface
  27. */
  28. private $config;
  29. /**
  30. * @param \Magento\Framework\App\Config\ScopeConfigInterface $config
  31. */
  32. public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $config)
  33. {
  34. $this->config = $config;
  35. }
  36. /**
  37. * Get maximal width value for resized image
  38. *
  39. * @return int
  40. */
  41. public function getMaxWidth(): int
  42. {
  43. return (int)$this->config->getValue(self::XML_PATH_MAX_WIDTH_IMAGE);
  44. }
  45. /**
  46. * Get maximal height value for resized image
  47. *
  48. * @return int
  49. */
  50. public function getMaxHeight(): int
  51. {
  52. return (int)$this->config->getValue(self::XML_PATH_MAX_HEIGHT_IMAGE);
  53. }
  54. /**
  55. * Get config value for frontend resize
  56. *
  57. * @return bool
  58. */
  59. public function isResizeEnabled(): bool
  60. {
  61. return (bool)$this->config->getValue(self::XML_PATH_ENABLE_RESIZE);
  62. }
  63. }