0

In Drupal 7 (Commons 7.x-3.46).

I've created a new content type, by which each user can upload images and build a personal picture-gallery.

How can I now associate the last-uploaded-image to the user's profile-picture?

Amodule-based solution is preferable. Is there a better way of doing this, ie without a new content type? Essentially I'm looking for a user-friendly way for users to upload and show their profile pictures.

  • Enable field collection module and field permission module. Create collection field with an image type and set its number cordiality to unlimited and then add this field collection in /admin/config/people/accounts/fields (you can also set its cordiality). While adding field collection field in /admin/config/people/accounts/fields you will see the new permissions block and you can control who can add/view/update this field collection. – usmanjutt84 Aug 29 '18 at 10:48
  • The above comment only to show the all images for current user.. – usmanjutt84 Aug 29 '18 at 10:52
  • Thank you for your comment. This is an interesting approach, but I've come across a few problems: The profile picture isn't taken from the field collection field. It is ignored. An image field in the account settings is possible, but even then I needed the user_picture_field module to do the bridging. It works, but only with an image field, not with a collection field. The field_permissions module uses roles. In my case I'm working with flags, ie a user's photos can be viewed only by users flagged with an "i trust this person" flag. regards, d – dnoncoder Aug 30 '18 at 14:34
  • I've found the user_picture_field module almost does it. But it only works with image fields in the user entity or in the profile2 entity. How can I tweak it to work with another content type? – dnoncoder Sep 1 '18 at 22:11
  • I have posted the answer, please follow the steps and let me know if it works. Thank – usmanjutt84 Sep 3 '18 at 16:53
0

Amodule-based solution is preferable. Is there a better way of doing this, ie without a new content type? Essentially I'm looking for a user-friendly way for users to upload and show their profile pictures.

I would like to recommend field_collection module as I already mentioned in the question's comments.

Step # 1: Enable field_collection module.

Step # 2: go to /admin/config/people/accounts/fields and add a new field named as User Gallery (machine name should be field_user_gallery) and choose field type as "Field collection" and save. Note that you can set the field cardinality as you like.

Step # 2: Go to admin/structure/field-collections and add a new image field named as Image (machine name should be field_image) and choose field type as "Image" and save. (It might already be added in the existing field list.)

Step # 3: Download custom module from custom_user_profile and extract to your module directory. Make sure extracted directory name is custom_user_profile and then enable it.

That's all. I hope it will work for you as works for me.

  • Thank you for your helpful answer. It works! In Drupal-Commons it conflicts with the edit_profile module. After running a few patches on that module, and changing the form_id in your custom module to 'edit_profile_user_profile_form' it now works perfectly. Thanks again. – dnoncoder Sep 6 '18 at 17:03
  • @dnoncoder Glad to know it worked for you and I apologize not to mention such changes. I should have. Thanks – usmanjutt84 Sep 7 '18 at 10:03
  • @dnoncoder, it should be a new question. – usmanjutt84 Sep 8 '18 at 21:22
  • thank you, i have asked a related question here: drupal.stackexchange.com/questions/269002/… – dnoncoder Sep 8 '18 at 22:48
  • thinking more about this, wouldn't it be easier to flip it around: to leave the profile picture as it is, and to create a new entry in the field collection every time a user changes the profile picture? – dnoncoder Sep 9 '18 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.