Image.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * An image, embedded in a multipart message.
  11. * @package Swift
  12. * @subpackage Mime
  13. * @author Chris Corbyn
  14. */
  15. class Swift_Image extends Swift_EmbeddedFile
  16. {
  17. /**
  18. * Create a new EmbeddedFile.
  19. * Details may be optionally provided to the constructor.
  20. * @param string|Swift_OutputByteStream $data
  21. * @param string $filename
  22. * @param string $contentType
  23. */
  24. public function __construct($data = null, $filename = null, $contentType = null)
  25. {
  26. parent::__construct($data, $filename, $contentType);
  27. }
  28. /**
  29. * Create a new Image.
  30. * @param string|Swift_OutputByteStream $data
  31. * @param string $filename
  32. * @param string $contentType
  33. * @return Swift_Mime_EmbeddedFile
  34. */
  35. public static function newInstance($data = null, $filename = null, $contentType = null)
  36. {
  37. return new self($data, $filename, $contentType);
  38. }
  39. /**
  40. * Create a new Image from a filesystem path.
  41. * @param string $path
  42. * @return Swift_Mime_EmbeddedFile
  43. */
  44. public static function fromPath($path)
  45. {
  46. $image = self::newInstance()->setFile(
  47. new Swift_ByteStream_FileByteStream($path)
  48. );
  49. return $image;
  50. }
  51. }