2

I'm uploading a PNG image into my assets folder and linking to it from my css file - standard stuff, nothing special. However the PNG image is returning with a 500 error in the console and not displaying. When I visit the image directly in the browser I get a lot of numbers and:

Template Error

Unexpected character ""

Screengrab of error

I'm working locally with MAMP Pro and I've only recently restored my computer from scratch. I'm wondering whether this is a Craft issue or potentially a MAMP issue. It works fine if I use a Jpg instead or an externally hosted PNG.

This is also happening when I link to it with an img tag

2

Host your image assets outside of the templates directory. A more appropriate place for UI assets is in the /public directory.

Craft is attempting to parse the image like it is a template, which is causing the Unexpected Character error.

  • Thanks. Didn't realise this and built my template structure wrong. Moved assets to the correct place and it works fine now – Adam Hughes Nov 18 '15 at 15:42
1

Try checking file permissions. This happens to me frequently when copying assets from different people on our team.

http://ifmeister.com/mamp-file-permissions-for-a-local-development-environment/

Use devtools or something else to pull up the image in your browser. If you can't open it, there's a file permission problem.

  • 1
    You may also want to look into hosting your image assets outside of the templates directory. A more appropriate place for UI assets is in the /public directory. – dgrebb Nov 17 '15 at 21:33
  • This was the issue. I had the assets folder inside Templates. I've move it out to the root of my public folder and it works now. Make this an answer and I'll mark it correct. – Adam Hughes Nov 18 '15 at 10:12

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.