OEmbedPhoto.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * OEmbedPhoto
  4. *
  5. * This file is part of Grav MediaEmbed plugin.
  6. *
  7. * Dual licensed under the MIT or GPL Version 3 licenses, see LICENSE.
  8. * http://benjamin-regler.de/license/
  9. */
  10. namespace Grav\Plugin\MediaEmbed\OEmbed;
  11. use Grav\Plugin\MediaEmbed\OEmbed\OEmbed;
  12. /**
  13. * OEmbedPhoto
  14. *
  15. * This type is used for representing static photos. The following
  16. * parameters are defined:
  17. *
  18. * url (required)
  19. * The source URL of the image. Consumers should be able to insert
  20. * this URL into an <img> element. Only HTTP and HTTPS URLs are valid.
  21. *
  22. * width (required)
  23. * The width in pixels of the image specified in the url parameter.
  24. *
  25. * height (required)
  26. * The height in pixels of the image specified in the url parameter.
  27. *
  28. * Responses of this type must obey the maxwidth and maxheight request
  29. * parameter.
  30. */
  31. class OEmbedPhoto extends OEmbed
  32. {
  33. public function getOEmbed()
  34. {
  35. $oembed = parent::getOEmbed();
  36. if ($this->embedCode && $this->oembed) {
  37. $width = $this->oembed->get('width');
  38. $height = $this->oembed->get('height');
  39. $this->attributes(['width' => $width, 'height' => $height]);
  40. }
  41. return $oembed;
  42. }
  43. }