Jump to content

Resolved - Images using only relative url in emails


Recommended Posts

I am trying to use the Newsletter feature. When I add images, they only include the relative url path (/images/myimage.jpg).

Where in the editor, template, cubecart, etc. can I set the path to be the full url.


Without the full url, the images break in the email. I've searched for hours and can't find where to put the full url.



Link to comment
Share on other sites

There are two parts to a newsletter/email: the skeleton that shows the heading, salutation, closing and footer; and then there is the main body content area.


In admin, click Email Templates in the left-side navigation. There is the Email Contents tab, the Email Templates tab, and an Import tab.


The Email Templates tab is where the skeletons are edited. Starting with the supplied skeletons in CubeCart, you can clone one and edit the new one to suit your needs. Click the edit icon for the Default Newsletter.


There is a new series of tabs:

General - this is the name of the newsletter, "March Madness", Winter Holidays", whatever. The recipient does not see the name. It is for your own use.

HTML Content and Plain Text Content - self-explanatory.


(In CubeCart, do not click the browser's Back button. There is a mechanism in place that will frustrate you to no end if you regularly do this to return to previous pages. Instead, click the place you want to go using the "breadcrumbs" just below the tabs.)


Click Newsletters in the left-side navigation. Then click the Create Newsletter tab. In addition to the tabs as mentioned above, there is a Test Send feature.


The Content tabs are used to create (or edit existing content templates) the body of the newsletter CubeCart will replace {$EMAIL_CONTENT} in the skeleton template with what is created here.


Would you like to create a newsletter to walk you through the steps involved?

Link to comment
Share on other sites

Ok, now I see. You are not understanding my question.


I know where to make a template (skeleton code) and I know where to create a newsletter (Newsletters).


The issue I'm speaking of is the insert images function of the editor itself. When using that button to insert an image into the newsletter or an email, it gets mailed off using the relative path (/images/mypic.jpg) and therefore is not visible when a user opens the email.


I need to figure out where I can change that function to include the full server path, so the images show in the email.


I realize I can do this manually on each image after it's inserted, but I'm trying to make it easy for my client.


I hope that makes sense.

Link to comment
Share on other sites

When the image Properties window pops up, you have the opportunity to Browse the Server. Assuming there are images available, and one is chosen, the resulting link will be a "relative" link. For example:



Before dismissing the Image Properties box, add {$STORE_URL}/ in front of the link in the URL field:



(Also, a bug in CubeCart will remove the backslashes used by Windows servers used as the folder separator. Be sure to replace the backslashes with forward slashes. Another bug will add CubeCart's branding to the skeleton template every time it is edited and saved.)


I agree that the routines to Create/Edit email-based templates and newsletters should have full URLs.

Link to comment
Share on other sites

My approach is to be in the CubeCart code that accepts the POSTed content, then preg_match for all instances of an image tag, and add the {$STORE_URL}/ part before it gets into the database.


/admin/sources/documents.email.inc.php, near lines 235-287.


There is also the possibility of using a <base href> in the templates. I just need to find where the template is stored that creates new templates.


Ok, there is no template to create new templates. (Well, there is, but it's not what we want.)


When a new skeleton template is being created, all that CKEditor gives us is a bare <html><head><title><body> structure.


So, we can edit the existing templates (the two created when CubeCart was installed and these two templates were loaded into the database) by adding:

<base href="{$STORE_URL}" />


This allows for the viewing of the image that just got inserted as the relative URL path is valid for the editor.


Then clone all others from those.


Yup. That works for me.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...