/** * Loads the image and returns an instance of Image class. * * @param string|File $image This can either be image file name that corresponds to File $key parameter, * or it can be an instance of Webiny\Component\Storage\File\File. * @param string|Storage $storage This can either be the name of the storage service or it can be an * instance of Webiny\Component\Storage\Storage. * NOTE: This parameter is not required if you pass the $image as * instance of Webiny\Component\Storage\File\File. * * @return ImageInterface */ public function image($image, $storage = 'local') { if ($image instanceof File) { return ImageLoader::load($image->getContents()); } else { if (!$storage instanceof Storage) { $storage = ServiceManager::getInstance()->getService('Storage.' . $storage); } $file = new File($image, $storage); return ImageLoader::load($file->getContents()); } }
/** * Attach a file to your message. * * @param File $file File instance * @param string $fileName Optional name that will be set for the attachment. * @param string $type Optional MIME type of the attachment * * @return $this */ public function addAttachment(File $file, $fileName = '', $type = 'plain/text') { $this->message['attachments'][] = ['type' => $type, 'name' => $fileName, 'content' => base64_encode($file->getContents())]; return $this; }
/** * Attach a file to your message. * * @param File $file File instance * @param string $fileName Optional name that will be set for the attachment. * @param string $type Optional MIME type of the attachment * * @return $this */ public function addAttachment(File $file, $fileName = '', $type = 'plain/text') { $attachment = new \Swift_Attachment($file->getContents(), $fileName, $type); $this->message->attach($attachment); return $this; }