Page 1 of 1

Help with embeding images :)

Posted: Mon Oct 01, 2007 3:56 am
by onvsop
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello, 

I am trying to enbed an image, and have it show up in the body of my email, is this possible.

Thanks in advance

Code: Select all

$email_body = "
            <html>
            <head>
            </head>
            <body>
            <p> Some Text </p>
            <p>I WANT MY IMAGE To SHOW UP HERE</p>
            </body>
            </html>";

$message =& new Swift_Message("Subject", $email_body, "text/html");
$part =& new Swift_Message_Part("<img src=\"" . $message_to_user->attach(new Swift_Message_Image( new Swift_File("images/image.png"))) . "\" alt=\"Alt Text\" />" );

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Oct 01, 2007 4:08 am
by chuckl

Posted: Mon Oct 01, 2007 9:18 pm
by onvsop
Thanks for your reply,

But how exactly do i get the image, to show up where i want in the body of the email.
I would like it displayed in the body of my email;

Code: Select all

$message =& new Swift_Message("My subject");
 
$part =& new Swift_Message_Part("Here's an image <img src=\"" . $message->attach(new Swift_Message_Image(
    new Swift_File("images/foo.png"))) . "\" alt=\"\" /> embedded");
 
$message->attach($part); // <--- This attaches the image into the end of the email, and then my email_body does not show up.
So what i need is to embed the image, and then somehow get the generated <img> tag with the embedded image ID and insert it into my message body.

Thanks :)

Posted: Tue Oct 02, 2007 7:34 am
by chuckl
For that I normally use the decorator plugin and a {LOGO_IMAGE} or similar identifier in the HTML message.