I'm using the ImageField module together with Imagecache to display a picture for one of my content types.

To display the content body I'm using Contemplate, I'm accessing the path to the image in the following way:


This usually works, but it breaks when someone uploads a picture with the same filename as the existing one. The file itself is then automatically named filename_0.jpg instead of filename.jpg, but the filename variable of the ImageField I'm accessing stays filename.jpg.

This of course leads to the old image being displayed. It seems the filename variable does not do what I expected, what would be the correct way to access the Imagecache generated files?


Using the Contemplate module is not recommended since it puts PHP code into the database which is generally considered a security vulnerability and non-performant.

You want to use theme('imagecache', ...) instead, which will return the HTML img tag with the proper path.

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.