问题
Trying to code an email template for Mailchimp, and I'm trying to be able to edit the background image tag of a via Mailchimp itself, so I dont need to go and change the code each time I want to send it out.
Is there a way to declare the background tag as an /@editable/ region so I can change thethe url in mailchimp? If so, how would I go about doing it?
Current code:
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="wrap banner3" style="border-collapse: collapse; -webkit-background-size: cover; background-image: url(https://gallery.mailchimp.com/78524444e0a13e2b163d98bed/images/135974c9-84e6-4f03-9fde-891a893c58a8.jpg); background-color: #24272c; background-size: cover; background-position: 50% 50%; background-repeat: no-repeat;" background="https://gallery.mailchimp.com/78524444e0a13e2b163d98bed/images/135974c9-84e6-4f03-9fde-891a893c58a8.jpg">
What Im hoping to do:
/**
* @tab Background Images
* @section Event Image
*/
/*@editable*/ Var event-bg-img = "https://gallery.mailchimp.com/78524444e0a13e2b163d98bed/images/135974c9-84e6-4f03-9fde-891a893c58a8.jpg"
[...]
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0" class="wrap banner3" style="border-collapse: collapse; -webkit-background-size: cover; background-image: url(event-bg-img); background-color: #24272c; background-size: cover; background-position: 50% 50%; background-repeat: no-repeat;" background="event-bg-img">
Obviously looking for a solution that is supported across the ridiculous amount of email clients.
回答1:
The current version of the MailChimp editor (as of Feb 26, 2015) does allow for making editable background-image
properties (sorta). The following code in your HTML template:
/*@editable*/background-image:url();
will produce an editable field like this:

By adding a URL to your background image the image will appear in your template.
For example:
url(http://placehold.it/350x150)

This would require you to upload the background image to MailChimp, then grab the URL and paste it into url()
, so it's not ideal. For intermediate to advanced users this solution might work well however.
来源:https://stackoverflow.com/questions/25380018/editable-background-images-in-mailchimp