0

I have a image field in profile2, the images that are added to the profile are uploaded to /sites/default/files

This will be a mess with a lot of profiles and 5 images per profile. Also when the images are deleted from the profile they still remain in the folder.

Is there a way have each user's profile2 images goto their own location or at least one folder with all the pictures?

Also I would to know if there is a way so when the picture is removed from the profile or the account is deleted all the pictures are deleted to?

I am using the latest version of Drupal

1

Hope this will help you.

In Drupal 7 you can use TOKEN module.

  • Download and install Token module.

  • By considering that you have add the new image field using the path admin/config/people/accounts/fields

  • Go to your image field settings(admin/config/people/accounts/fields) and edit the image field

    enter image description here

  • Click Browse available tokens link to show the available tokens

    enter image description here

  • In my case I'm saving my FILE DIRECTORY path name as profile-pictures/user-[current-user:uid]-[current-user:name]

    enter image description here

  • When ever you upload files it will be stored in the profile-pictures/user-UID-USERNAME

  • You can customize the FILE DIRECTORY path as per your requirement.

  • You can use file_delete and file_usage_delete to delete the file once removed.

  • To delete the folder you can use USER API hook_user_delete

NOTE:

  • You can also refer IMCE module.
|improve this answer|||||

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.