StaticResizeTrait.php 602 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * @package Grav\Common\Page
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Page\Medium;
  9. trait StaticResizeTrait
  10. {
  11. /**
  12. * Resize media by setting attributes
  13. *
  14. * @param int $width
  15. * @param int $height
  16. * @return $this
  17. */
  18. public function resize($width = null, $height = null)
  19. {
  20. $this->styleAttributes['width'] = $width . 'px';
  21. $this->styleAttributes['height'] = $height . 'px';
  22. return $this;
  23. }
  24. }