carl57272
carl57272

When I upload a new image in October, and then ask it to be displayed e.g. <img src="/imagesfilename.png"> it won't load in a browser

However, <img src="http://admin.sitename.com/storage/app/media/images/filename.png"> does load in a browser

I don't want to have pass all that data in my HTML, especially with admin in it.

My techie says "It is issue in October Cms, somehow the code added is being removed from plugins. "

Is he right? What does he mean? Is there a fix for this?

mjauvin
mjauvin

use this:

<img src="{{ 'images/fileName.png' | media }} " />
LukeTowers
LukeTowers

My techie says "It is issue in October Cms, somehow the code added is being removed from plugins. "

No idea what your techie is on, but it doesn't sound like he knows how to use October.

carl57272
carl57272

My techie is not an October expert, for sure.

Let me try and phrase this in a different way - <img src="/images/name.png"> in the HTML loads fine once my techie has done something. I'm not sure what he does, or why he needs to do it. I want to know why I just can't load images to the media library and then write normal HTML as above, and have the images load. What am I missing?

LukeTowers
LukeTowers

You can't just use /images/name.png as the URL to the image, because that's not where the image lives. The image is located at /storage/app/media/images/name.png because the media library lives at /storage/app/media. You can use a helper like the | media filter recommended above so you don't have to care about where the library is, but no matter what, if you want the images to load the URL you use has to reflect where they live (or at least a way to get to it).

My guess as to what your techie probably did was to change the server configuration so that requests to /images/name.png get automatically forwarded to the /storage/app/media/images folder. There are a number of ways to do that, and I'm guessing he probably picked modifying some code that gets overwritten if the system is updated, which is obviously a terrible choice.

If you'd like to work with someone that is an expert in these matters, then feel free to shoot me an email at octobercms@luketowers.ca.

carl57272
carl57272

Many thanks Luke - that makes a lot of sense

klas.wirholm
klas.wirholm

There was some issues with images in storage directory, after upgrade of October CMS, with relative urls, the media twig filter did not function with only "media". My solution, to get full url (witch is better SEO):

{{ '' | app ~ 'my-logo.png' | media }}

Last updated

1-7 of 7