3

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

4
  • What did you set the File System Path and the URL to? Is this a Craft 2 build?
    – Jay
    Commented Aug 24, 2018 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? Commented Aug 24, 2018 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 Commented Aug 24, 2018 at 19:24
  • Can you please update your question with a screenshot of the Asset volume settings?
    – Jalen Davenport
    Commented Aug 27, 2018 at 14:51

1 Answer 1

7

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.

4
  • 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 Commented Aug 28, 2018 at 17:23
  • It can be done, but why would you want to do that? Commented Aug 28, 2018 at 19:24
  • I want to find out what the system is capable of and what its limitations are Commented Aug 28, 2018 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
    Commented Mar 11, 2019 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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