1

When templating my Craft site, I have run into an issue with on both my Local & Server environments on the latest version of Craft. I am running a LAMP stack and I think I have been able to narrow down the issue to being a file directory issue or section config mistake.

My Blog/Index page functions perfectly and will include all asset fields without issue, yet when I click on a blog post to navigate to a blog/_entry, all assets stop functioning. Below is the twig code that I use. I have only one volume titled "images" sitting within the web/ folder.

enter image description here

{% for image in entry.featureImage %}
  <img src="{{ image.url }}" alt="{{ image.title }}" data-holder-rendered="true"/>
{% endfor %}

So the funky thing is that the {{ image.title }} entry seems to work perfectly and will call the image, but will not display it. Maybe this could be an issue with file organization? The same problem occurs with my global assets (logos).

Here's a screenshot of what this looks like in action.

Any direction is much appreciated! New to development & not the brightest crayon in the shed so I'm having difficulty figuring out how to approach this problem, although I didn't seem to locate any issues among the config/ files.

0
1

If the entry is in a subdirectory, the image path will be incorrect. If the images are in a folder called "assets" in your home folder:

image.url for your main page would be "assets/imagename.jpg"

image.url for your entries in "blog" SHOULD be "../assets/imagename.jpg" BUT it will still return just "assets/imagename.jpg" instead of jumping up a directory to get the assets directory. Therefore, no image found at blog/assets/imagename.jpg.

Depending on your setup you might try img src="{{ siteUrl }}/{{ image.url }}". This will fetch the full site path to the image every time no matter what where it's called from.

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.