voidlabs / mosaico

Mosaico - Responsive Email Template Editor

Home Page:https://mosaico.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

img src on public web server

luxlux opened this issue · comments

I have installed mosaico on the mac of my wife, which works as graphic artist on a unit of university as solution to build newsletters.

All image src refers to her local host, so the downloaded html which is not usable for her.

Which is a simple way, to produce a download, which uses img SRCs on a public web server?

A quick & dirty solution would be ok, it will be only used by her. I.e. it would be ok, if she simply uploads the files from "uploads" folder by hand to a predefined (hardcoded) server. But where can i get changed the img src in the downloaded html to such an hardcoded server?

I'm not really sure how the data flows in mosaico. i never used Knockout and always use pure javascript instead of jquery and such.

My first thought was to do it in express in main.js app.post('/dl/', function(req, res). with replacing the source. but this is even not simple because DOM is not part of node.js, and the element is not so trivial:

<img border="0" hspace="0" align="center" vspace="0" width="166" style="border: 0px; display: block; vertical-align: top; height: auto; margin: 0 auto; color: #3f3f3f; font-size: 13px; font-family: Arial, Helvetica, sans-serif; width: 100%; max-width: 166px; height: auto;" src="http://localhost:9006/img/?src=http%3A%2F%2Flocalhost%3A9006%2Fuploads%2F3a46823647eaaf8fbe6b7f5df2cc2ffa_preview_featured.jpg&amp;method=resize&amp;params=166%2Cnull">

What is a better point to do it?
Which script produces the source, when a picture will be added?

Or is there a solution in the template to use image links instead of uploading images?

thanks
Lutz

commented

You don't have to understand DOM in order to replace a string pattern, just look for every occourence of "http://localhost:9006/img/?SOMETHING" and replace them with your own static images.

Otherwise host your mosaico backend in a public url instead of localhost and the generated urls will be on the url: this way your backend.

Which script produces the source, when a picture will be added?

No script produces sources. Mosaico simply takes a "backend service" that will use to ask for resized/cropped version of the uploaded images. There's no "source". Dealing with making this stuff static or ready to be sent is a "backend" job and is not part of the library.

Or is there a solution in the template to use image links instead of uploading images?

No. Mosaico needs to manipulate images on the fly, so it only works with local images. You can make it work with remote images, but this require much more skills than the search&replace discussed on top of this answer, so I suggest to stick with that.