Summary

When using JHTML::_('image.site') to output a image, wrong image path will be chosen in some cases. It occurs when same image name occurs in different paths.

For example I have image named my_image.jpg which is in directories /images/products/thumb, /images/products/medium, /images/product/original (actual images in those directories are different, only the name is same).
Now when in a single page displaying this image from the /images/products/thumbs directory, all works fine. But when trying to display it from the /images/products/medium directory, for example, on the same page somewhere, then the /images/products/thumbs path is chosen, not the /images/products/medium path as specified.

Digging through source code I discovered that Joomla caches those paths. And the problem occurs because cache key doesn't include the directory of the requested image, only the name of the image.
In first request, path (/images/products/thumb) is cached with the key. When requesting same image again, but from different path then first it looks from the cache, finds the path by the cache key (which includes basically the image name only), finds a match and returns it, result would be path /images/products/thumb.

The problem source is in file /libraries/joomla/html/html/image.php in method site().
Opened On:
18 Feb 2009, 19:44 by Siim Viikman
Status:
Open

Filed Under

  • Developer
  • Joomla! Libraries
  • PHP 5.2.x