2

I wanted to include some uploaded assets (images) in an entry. The .url property in twig outputs the proper URL, in my case:

http://localhost/craftcms/web/image/photo-2017-04-02-16-20-53-1.jpg

However, that link is broken. Following it leads to a 404 error page:

Template not found: image/photo-2017-04-02-16-20-53-1.jpg

Viewing it in the admin panel preview also displays a broken image sign.

If I disable the Public URL switch in the asset settings, the image display fine in the admin panel, but obviously I cannot use them in public pages.

I wasn't able to find a working fix for this. I tried the multiple-environment config solution from these forums just in case, but it did not help me.

Update: here is a screenshot of my Assets volume settings: enter image description here

  • What did you set the File System Path and the URL to? Is this a Craft 2 build? – Jay Aug 24 '18 at 14:14
  • The public URL needs to be publicly accessible, so in your web root folder. (the "web" folder by default in a craft3 project) Is your assets folder in there? – billythekid Aug 24 '18 at 14:38
  • This is a Craft 3 install. The public URL is indeed publicly accessible - inside the web folder as you suggested (see original post). The file system path - I also tried putting it in the web folder, as well as outside of it. No avail – Dwarf Vader Aug 24 '18 at 19:24
  • Can you please update your question with a screenshot of the Asset volume settings? – Jalen Davenport Aug 27 '18 at 14:51
5

The issue is that your Asset Volume URL is @web/image but your Asset Volume path is @webroot/assets/art

That means that Craft will look for the images on disk (to do transforms, etc.) in web/assets/art but it will generate URLs for frontend requests that point to http://example.com/image -- where presumably nothing exists.

These should probably be:

  • URL: @web/assets/art
  • Path: @webroot/assets/art

...assuming that the web/assets/art/ directory is where these images live.

  • Thank you, this worked perfectly. Question: what if I want to have my images stored outside webroot, but have public URLs? How can I achieve that? Thank you – Dwarf Vader Aug 28 '18 at 17:23
  • It can be done, but why would you want to do that? – andrew.welch Aug 28 '18 at 19:24
  • I want to find out what the system is capable of and what its limitations are – Dwarf Vader Aug 28 '18 at 21:38
  • @andrew.welch, can you elaborate on the configuration required for storing the assets on disk outside of the web root? My use case for doing this is in a development environment where I'd like the base asset path to be an environment variable storing a path to a shared disk location where assets are maintained for all developers that are developing the site. I can serve the assets from another base path using some Nginx configurations, but I'm interested to know if it's possible without this. – Tim Everts Mar 11 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.