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.

CommentFileSizeAuthor
imagecache-no-lang-prefix.patch775 bytesmsteurs
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

matslats’s picture

Patch works!

vurt’s picture

Patch 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.

hedac’s picture

thank you thank you thank you..
it works now on other languages. This is critical.

fizk’s picture

Status: Active » Closed (won't fix)

What about sites that need the language prefix?

tomotomo’s picture

Status: Closed (won't fix) » Needs review

This 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.