Image.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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,
  25. $contentType = null)
  26. {
  27. parent::__construct($data, $filename, $contentType);
  28. }
  29. /**
  30. * Create a new Image.
  31. * @param string|Swift_OutputByteStream $data
  32. * @param string $filename
  33. * @param string $contentType
  34. * @return Swift_Mime_EmbeddedFile
  35. */
  36. public static function newInstance($data = null, $filename = null,
  37. $contentType = null)
  38. {
  39. return new self($data, $filename, $contentType);
  40. }
  41. /**
  42. * Create a new Image from a filesystem path.
  43. * @param string $path
  44. * @return Swift_Mime_EmbeddedFile
  45. */
  46. public static function fromPath($path)
  47. {
  48. $image = self::newInstance()->setFile(
  49. new Swift_ByteStream_FileByteStream($path)
  50. );
  51. return $image;
  52. }
  53. }