phoenix_markdown icon indicating copy to clipboard operation
phoenix_markdown copied to clipboard

Issue rendering images with EEX-generated urls

Open worace opened this issue 5 years ago • 2 comments

I am trying to use the phoenix route helpers (specifically the static_path helper) to display an image from my app's static directory.

Rendering an image manually works (image gets displayed):

![My Image](/images/my_image.png)

But using the eex tag to embed the URL does not. This:

![My Image](<%= Routes.static_path(@conn, "/images/my_image.png") %>)

Just gets rendered in the document as ![My Image](/images/my_image.png).

I'm not familiar with how the library is put together but I wonder if this might be something similar to https://github.com/boydm/phoenix_markdown/issues/8.

worace avatar Dec 28 '19 21:12 worace

Hi Horace.

I'm trying to replicate this by adding a test specific to image pages. It seems to be working for me.

You can see the test in the branch image_path.

Can you confirm that server-side parsing is turned on for that file by adding something really simple like <%= 11 + 2 %> and see that 13 gets rendered out to the page?

Thanks, --Boyd

boydm avatar Jan 27 '20 22:01 boydm

Thanks Boyd - I just tested a basic <%= 2 + 2 %> example and confirmed that it does work.

I also have already been using the route helpers to render links successfully. So a bit of markdown like this:

[Test](<%= Routes.test_path(@conn, :show) %>)

Is working to generate:

<a href="/test">Test</a>

But for some reason when I try the same thing with an image it is not coming through:

![My Image](<%= Routes.static_url(ContourWeb.Endpoint, "/images/docs/my_image.png")%>)

So I have just been entering those paths manually, e.g.

![My Image](/images/docs/my_image.png)

Which works fine, but I think it's nice to use the static_url helper if you can because you get the digested asset urls that way.

Thanks for looking, let me know if I can give any more info.

worace avatar Jan 28 '20 16:01 worace