crescentryoshi
Hello, so I’m trying to load images using the username of each post as part of the route where the profile pictures are, basically it’s this format.
assets/profilepics/username.png
I tried doing it like this <img src=“static_path(@conn, “/assets/profilepics/#{@posts.user.name}.png”) %>”></img>, but it didn’t do the trick. What would be the correct way to add the username to the section of the tag that requires it?
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
For you see any errors or what do you see instead of the username in the generated HTML?
Also you haven’t
<%=in your post, is that by accident or in your code as well?crescentryoshi
In my code as well, I tried doing it with <%= as well but it still shows up as a broken image. And no error per se, just the broken image icon instead of the image in the path.
crescentryoshi
Also, I do show the user name in one of the posts sections, and it’s loaded fine, so the path not loading fine has to do with my syntax for the img src tag. I’m just not sure where, this is my first project with Phoenix/elixir and I’ve been having some troubles with syntax/logic while working on it.
NobbZ
Then please tell us how the generated HTML looks like. The syntax looks fine assuming you open the
<%=correct.crescentryoshi
It looks like this without the <%=, if I add the <%= I get an incomplete expression error.
== Compilation error in file web/views/thread_view.ex ==
** (TokenMissingError) web/templates/thread/show.html.eex:39: syntax error: expression is incomplete
(eex) lib/eex/compiler.ex:45: EEx.Compiler.generate_buffer/4
(eex) lib/eex/compiler.ex:54: EEx.Compiler.generate_buffer/4
(phoenix) lib/phoenix/template.ex:378: Phoenix.Template.compile/2
(phoenix) lib/phoenix/template.ex:186: anonymous fn/3 in Phoenix.Template.“MACRO-before_compile”/2
(elixir) lib/enum.ex:1899: Enum.“-reduce/3-lists^foldl/2-0-”/3
(phoenix) expanding macro: Phoenix.Template.before_compile/1
web/views/thread_view.ex:1: Forum.ThreadView (module)
(elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6
NobbZ
And how exactly does the code look like that generates this error and the wrong output? The first output clearly shows you are not using
<%=, the error shows you are using it probably wrong.crescentryoshi
<%=img src="static_path(@conn, "/assets/profilepics/#{@posts.user.username}.png")%>">This would be the code that generates the error.NobbZ
Only the elixir stuff needs to be in
<%= %>:On a first glance at least…
crescentryoshi
Sweet! That did it. Now the HTML looks like this
<img src="/assets/profilepics/pmgbove.png">, still shows up a broken image icon but I’ll figure that one out. Thanks a lot!UsamaHaide0786
<img src={image_url}>thats how it worked for me