1

I'm trying to send some assets links through email, but using {{ siteUrl ~ file.link }} returns an url with double forwards slashes like: http://example.com//public/assets/sdfsdfds.jpeg

I couldn't find a method on the AssetsFileModel that generates a direct link to it. Is there an easy way to do this?

Thanks!

3

What if you just use <a href="{{ file.url }}">? So, without the siteUrl part? If your Asset source's URL setting is correct (so, the complete url, preferably using {siteUrl}), that should do the trick ...

5
  • I tried that, but it only returns the file path, like /public/assets/sdfsdfds.jpeg without the website url. Mar 23 '15 at 20:10
  • And what's your assets source's URL setting?
    – Paul
    Mar 23 '15 at 20:20
  • File System Path: {basePath}/assets/uploads/ URL: /public/assets/uploads/ Mar 23 '15 at 20:25
  • 1
    Url should be the complete url to your file, so for instance {siteUrl}public/assets/uploads. That way, {{ file.url }} always works, even if you change the siteUrl config setting.
    – Paul
    Mar 23 '15 at 20:33
  • Ohh man, that's it. Haha. Thanks for your time @paul-verheul appreciate that. You might wanna add that to your answer for future reference. Thanks again. Mar 23 '15 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.