Hi,

I set up imagecache to display a thumbnail of a user profile pic in a template like this:


$pic_link = $node->picture;

echo theme('imagecache', 'w40', $pic_link);

that works... BUT, when a user changes his/her profile picture, imagecache DOES NOT update the thumbnail...... only if I flush images from admin/imagecache, it will work fine...

but I donno why it doesn't automatically update on change? Does it matter if pictures are called the same, like for user uid 1, the file name is always "picture-1.jpg" ?

k.

Comments

nosro’s picture

Nate Haug at Lullabot built a tutorial and a module to fix this.

coupet’s picture

probably need to call function imagecache_image_flush($path)

----
Darly

mattcasey’s picture

Adding this to a submit handler worked for me when profile pics were getting stuck in the tmp directory, thanks!


function mymodule_form_alter(&$form, $form_state, $form_id) {
	if($form_id == 'user_profile_form') {
		// Add submit handler
		$form['#submit'][] = 'mymodule_user_profile_form_submit';
	}
}
function mymodule_user_profile_form_submit($form, &$form_state) {
	// Flush portrait pic
	imagecache_image_flush($form_state['values']['_account']->picture);
}
webastien’s picture

I didn't see lulabot's module but I corrected this problem in a same way.
In my case, imagecache_image_flush function was bugged so, I changed it to this :

function imagecache_image_flush($path) {
$presets = _imagecache_get_presets();
foreach($presets as $presetid => $presetname) {

// $path = file_directory_path() .'/imagecache/'. $presetname .'/'. $path;
$preset_image = file_directory_path() .'/imagecache/'. $presetname .'/'. $path;

file_delete($preset_image);
}
}

Dirty Bird’s picture

Just to be a complete idiot, where do you put that JS snippet? I am havinvg the same problem. like I said, Im an idiot

v1nce’s picture

Try out the ImageCache Profiles module.

ImageCache_Profiles module allows you to set user profile pictures that are consistent throughout your site and allows avatars on the user profile pages to be a different size.

Please submit any bug reports or feature requests after giving it a spin.