Render Images on SSR Templates

I’m trying to render a template server side using the meteorhacks:ssr package. Does anyone know how to render images in templates on the server? Do you have to put your image in the private folder? Do you need a special path, or do you have to render the image with the meteorhacks:ssr package? Thanks!

<img alt="Paintbrush" src="/paintBrushLogo.png">

Server side rendering just means that the html is generated on the server not on the client. So nothing special happens with img-tags when rendered on the server. (Whats rendered in the end is just a string).

The question is therefore where to put static assets: --> in public folder:

public/paintBrushLogo.png

in your case.

So that’s not entirely correct for my use case (not sure about others). I am using webshot to actually create a pdf from a server side route, and linking to images in the public folder didn’t seem to work for that. What did end up working was including the entire url in the route. So in local development mode it would be http://localhost:3000/[your route], and in production it would be http://[your domain]/[your route]

same problem. is solved for me by providing a absolute url to image, including the domain. but instead embed your domain in the code, you can use Meteor.absoluteUrl function as helper in your template.

<img src="{{absoluteURL "images/yourImage.png"}}" />

Template.yourTemplate.helpers({
       absoluteURL: function (uri) {
           return Meteor.absoluteUrl(uri);
      }
});

but, i search a way to send an a rendered image, not img with rsrc to my domain :frowning:

1 Like

I recently migrated from Digital Ocean to Galaxy, and once again images are not loading correctly for me. Are you using Galaxy for hosting, or another hosting platform?