Serve static files from a custom folder/uri

I added an extra plug to serve uploaded images which I store in a custom folder and serve from a custom URI path /media:

plug Plug.Static,
   at: "/media",
   from: {:my_app, "priv/uploads"},
   gzip: false

plug Plug.Static,
  at: "/",
  from: :my_app,
  gzip: false,
  only: ~w(css fonts images js favicon.ico robots.txt)

But to serve these files from web pages I now have to prepend media to the URL like so:

<%= img_tag "/media" <> input_value(f, :media) %>

Is there a better way to achieve that?

I started a thread on Google’s group where I posted a suggestion:
https://groups.google.com/forum/#!topic/phoenix-core/F9spAUfS-G8

Head there for further discussion on this topic :v:

1 Like