10000 [TwigBridge][Mime] Use content for images attached to emails by aleho · Pull Request #60098 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge][Mime] Use content for images attached to emails #60098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Symfony/Bridge/Twig/Mime/WrappedTemplatedEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ public function toName(): string
* some Twig namespace for email images (e.g. '@email/images/logo.png').
* @param string|null $contentType The media type (i.e. MIME type) of the image file (e.g. 'image/png').
* Some email clients require this to display embedded images.
* @param string|null $name A custom file name that overrides the original name (filepath) of the image
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a new parameter is a new feature, which should go in 7.3 rather than in 6.4. Please separate that from the bugfix.

*/
public function image(string $image, ?string $contentType = null): string
public function image(string $image, ?string $contentType = null, ?string $name = null): string
{
$file = $this->twig->getLoader()->getSourceContext($image);
$body = $file->getPath() ? new File($file->getPath()) : $file->getCode();
$this->message->addPart((new DataPart($body, $image, $contentType))->asInline());
$part = (new DataPart($body, $name ?: $image, $contentType))->asInline();
$this->message->addPart($part);

return 'cid:'.$image;
return 'cid:'.$part->getContentId();
}

/**
Expand Down
Loading
0