Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Images won't be displayed in some pages

Started by Raphael Hernandes 7 years ago · 2 replies · 456 views
7 years ago

Hi,

I've been using grav on my website for a while and, a few weeks ago, some pages stopped displaying images.

The original file is still on the server, absolutely nothing has changed.

Other pages, on the other hand, still display images properly.

I've tried comparing the pages going through this issue to the ones that have been operating normally, but I could not find any difference between them.

Here are two examples with broken images:
https://privacidadeparajornalistas.org/
https://privacidadeparajornalistas.org/guias/criptografe-seu-hd-bitlocker

And here one in which they are working properly:
https://privacidadeparajornalistas.org/guias/armazene-arquivos-forma-privada-nuvem

What should I do to fix that? Thank you!

7 years ago

Hi,

I've just gave a look into your code, and for your second page, here's the HTML code for the broken image :
<figure role="group"><img src="https://privacidadeparajornalistas.org:80/home/line.png"></figure>

And on the third page, where everything's fine, it's more like :
<p><a rel="lightbox" href="/user/pages/02.guias/09.armazene-arquivos-forma-privada-nuvem/sync_main_page.PNG"><img alt="" src="/images/6/0/f/d/5/60fd5e256aac6b6721c2234e86e836f389e78c6a-syncmainpage.png" /></a></p>

So as you can see, you're using relative paths in this second one.
My guess is that in the first case, you may have made a mistake in the markdown, by using an absolute link. Ex :
(my_resource)[http://my_site.com/pathto/my_resource] )
And in the second case, you used the correct technic of Grav Streams. Ex :
(my_resource)[theme://images/my_resource]

But maybe I'm wrong.

It may be a CSS pointing failure. Also, if the first mistake I quoted is due to a template in wich you add some custom HTML with resource pointing, I suggest you to use the url() technic to point to where you want. Ex :
<img src="{{ url('theme://images/my_resource.jpg') }}" alt="My resource" />

For <a> links, you should compose your url like this :
<a href="{{ page.find('/desired-page/desired-subpage').url }}">...</a>
<a href="{{ base_url }}/desired-page/desired-subpage">...</a> (this one must be verified. Here's the online doc about it.

last edited 03/05/19 by Romarain
7 years ago

Thanks a lot @Romarain!

As a matter of fact, they were all using relative paths.

The second, solution
<img src="{{ url('theme://images/my_resource.jpg') }}" alt="My resource" />
worked, though.

The thing is, the pages (both having and not having the issue) use the same template and everything in them is pretty much the same.

What further steps should I take in order to analyze what is causing this problem and be able to continue using markdown for images in all the pages?

Thank you once again.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 54 11 hours ago
Support · by Anna, 3 days ago
2 60 14 hours ago
Support · by Justin Young, 15 hours ago
1 30 15 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 57 5 days ago