Problem:
Since 6.x-2.0-beta12, images generated from theme_imagecache() have a language prefix in the url. This causes a performance hit as, when loading the image on a page, it passes the Drupal bootstrap phase... On a page with many images, this performance hit can become really serious, as I recently noticed on one of my clients' production sites.
Analisis:
The imagecache_create_url() function, which is called in the theme_imagecache() function, uses url() to generate the final image path which is used in the src-attribute of the image being themed. The url() function, depending on the language negociation strategy selected, adds the language prefix to the path returned.
Solution:
A patch is added to this issue, which can be used to solve the problem. By simply setting the 'language' attribute of the url functions used in imagecache_create_url() to FALSE, language prefixes are omitted.
| Comment | File | Size | Author |
|---|---|---|---|
| imagecache-no-lang-prefix.patch | 775 bytes | msteurs |
Comments
Comment #1
matslats commentedPatch works!
Comment #2
vurt commentedPatch works. Thank you!
This patch is not only performance related. It also fixes the problem that Drupal gets called simultaneously when there are multiple imagecache images on a page. For a user who is logged in this can lead to errors because the user.module (line 270) has no locks to protect against simultan calls:
Duplicate entry '8-7' for key 'PRIMARY' query: INSERT INTO users_roles (uid, rid) VALUES (8, 7) in modules/user/user.module in line 260.
Comment #3
hedac commentedthank you thank you thank you..
it works now on other languages. This is critical.
Comment #4
fizk commentedWhat about sites that need the language prefix?
Comment #5
tomotomo commentedThis is a bug specifically on sites with language prefixes. The problem is that there is not nor should not be a language specific version of the imagecache file. It should use the same file. Unfortunately, adding the language prefix to the url results in 404.