Title speaks for itself really. It would be great if the users' pictures could be migrated along with profile fields, presumably into an imagefield field.
I've been hacking away on the module for my own use and I see 2 issues:
Firstly, the only database reference for the picture is in the users table rather than in the profile_fields and profile_values tables. This means the PHP loop which iterates over the profile tables can't handle the picture field creation. As far as I can see, either some of the field creation code needs to be duplicated, or all of it needs to be moved to a function somehow.
Secondly, the user picture is not recorded in the database as an uploaded file (i.e. in the files table) since it is not attached to any node. This means that either each image file has to have its existing location registered in the files table before linking it to the imagefield field, OR each image file has to be copied and saved to the new node.
I'll happily work on a patch but I wonder what anyone else thinks is the best approach for the 2 issues above. Or does someone want to implement it themselves?
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | profile_migrate-771008_2.patch | 7.35 KB | morbiD |
| #1 | profile_migrate-771008.patch | 3.6 KB | morbiD |
Comments
Comment #1
morbiD commentedHere's a patch.
It creates a new imagefield field called field_portrait if any of the users to be migrated have a picture uploaded. Then, for each user profile being migrated, it saves a copy of their picture to a portraits sub-directory in the default files directory. Finally, it attaches the copied file to field_portrait in the new profile node.
I went with duplicating the picture file rather than registering the original to avoid future file deletion issues. You don't want to delete your migrated node and find the original user picture goes missing or vice versa.
The patch seems to work fine for my own current needs. If anyone wants this feature please comment and feel free to test/alter the patch.
Comment #2
AaronCollier commentedComment #3
betarobot commentedIt's a good suggestion and will probably work for many, but I have a few concerns:
1. This way (as image field) user picture will not be shown in comments (at least unless you mingle with your theme)
2. Using services as gravatar will be impossible as they only connect with user.module
So if this patch will be committed, migrating a user picture should be optional and with some explanatory message for massive change in functionality.
Comment #4
morbiD commentedGood feedback. I hadn't really considered that since in my case, I just needed a quick way to duplicate 50 or so user profiles into nodes, before deleting the profiles. I was not actually going to use the Content Profile module afterwards.
Anyway, I will try to make the feature optional if I have time.
Comment #5
morbiD commentedHow's this?
I added a checkbox setting under an "Advanced options" fieldset, which is unchecked by default, and has a clear warning that other modules won't interact with migrated avatar images.
If it's checked, the validation I added also makes sure the imagefield module is enabled before attempting migration.
Comment #6
izmeez commentedsubscribing
Comment #7
betarobot commented@ -morbiD- sounds right!
The only point I'm not yet sure If I'll use content profile at all yet :)