When more images with the same name are in a directory tree, the sfImageSourceFile class will find all images, not only the exact one.
An exemple will be certainly more explicit :
There is an image directory tree content exemple :
web/
uploads/
back.png
assets/
back.png
if i call the url "thumbnails/original/back.png", the rendered image isn't the "uploads/back.png" image, but the "uploads/assets/back.png"
Why ? Just because the way the sfImageSourceFile class found image is no much clear.
The problematic line is the following one :
$files = sfFinder::type('file')->name(array($file.'{.jpg,.png,.gif,.jpeg,}'))->in(sfConfig::get('sf_upload_dir').$path);
By default, sfFinder will search recursively in the given directory (check for the sfFinder::search_in() method, used by the sfFinder::in() method).
So, all file who is named 'back' in all directory tree under the given one will be founded by the sfFinder call.
A simplest solution is to add a maxdepth(0) call in the sfFinder construction, like this :
$files = sfFinder::type('file')->name(array($file.'{.jpg,.png,.gif,.jpeg,}'))->maxdepth(0)->in(sfConfig::get('sf_upload_dir').$path);
In this way, the file search will only search in the exact directory path, not all childrens.
A better way (more configurable) could be to add a configuration case who allow or forbidden deep search.