dynamic profile image

Events happening in the community are now at Drupal community events on www.drupal.org.
katerega's picture

Am trying to display a profile image submitted by a webform on registration but cant figure out how to do it. i can display a static image but can't display image submmitted by the form. anyone know any module or code that does that, thanks, coz have been looking for it for a week now

Comments

It's not hard to do with the

cavinm's picture

It's not hard to do with the profile 2 module, however you can check this out https://www.drupal.org/project/reg_with_pic

Hi Cavin, can the photo

katerega's picture

Hi Cavin, can the photo upload be displayed separately from the initial registration? coz i failed to filed a way of splitting them that's why i resorted to using webform to do the registration since it was giving me a lot of flexibility in display as i wanted. please if there is any way the pgoto upload can be on a separate page from that of registration let me know. coz i failed to separate it

clarity...

benjaminkyta's picture

Are you using webforms (the module) to register users?
Or are you talking of the default Drupal user registration form?

How and where do you want to display this image? Is it in a tpl file? Views?

i extended the default drupal

katerega's picture

i extended the default drupal user registration form to use webform to register due to the requirements i wanted. I want to display the image in the tpl file using a block

Use Views

ElitPeter's picture

Just use views to display what ever you are displaying. views has helped me display almost anything i ever wanted to display.

Unfortunately, views wont

benjaminkyta's picture

Unfortunately, views wont display data from Webforms module. Thats if he is using that module. Otherwise if its the default forms, that should help.

webform submitted content viewing

katerega's picture

Am using webforms with data table module and sqlviews module, so am using the web form module to register a new user but i want to display a photo that is uploaded on registration on the home page using a block am trying to use the db_select() function, any ideas how i can do it or any better way STEP BY STEP on how to display photo uploaded via a webform. thanks

First steps ...

lwanga.matovu's picture

Hello katerega,

First question ... have you been able to attach the uploaded image to its user using this method?

If so, then we can proceed to how you can access the image?

yes Matovu, when i register a

katerega's picture

yes Matovu, when i register a user using the webform, the submission in the database shows that a photo is attached to the user and its stored in the default/image/file directory and with a unique uri url stored in the table drfa_file_managed

Hi Peter, i tried views but

katerega's picture

Hi Peter, i tried views but they don't show the profile image dynamically, maybe if u have a step by step how to. on how to use the views to show a logged in user details. they show the username but without use photo

my code in the custom module

katerega's picture

my code in the custom module looks something like this,
function MBlock_block_view($delta = '') {
$uid = "150";

$result = db_query('SELECT n.uri FROM drfa_file_managed n WHERE n.uid = :uid', array(':uid' => $uid));

$block['content'] = t(' @host ',array(
'@user' => format_username($user),

foreach ($result as $record) {
'@photouri' => $result->fetchColumn(0);
// echo ";";
}

));
return $block;
}

anywhere am going wrong, please i stand to be corrected.

this function is supposed to get me the url for the photo so that the block can display the photo dynamically from the database basing on the logged in user thanks

Feedback ...

lwanga.matovu's picture

Hey katerega,

This is what I think.

Your approach seems flawed. The UID field in the file_managed table only indicates who uploaded the image.

With this approach and in case you allow your users to upload more images, your query will return ALL the images uploaded by a user.

In this situation, how will you:

  1. know if the uploaded file is an image
  2. know which image is the profile image.

But nevertheless, if you still wish to continue down this path, what I would change in your code is as below.

Please keep in mind that this is untested and I do not recommend this approach one bit.

I would recommend the approach suggested by cavinm (reg_with_pic module) or the Profile module.

/
* this line returns the actual URI
* ... I think! Test!
*/
$result->fetchColumn(0)

/

* you need to convert that URI into an image
* ... something like this, again TEST and check.
*/
echo '<img src="' . file_create_url($result->fetchColumn(0)) . " />';

There is a thread

ElitPeter's picture

There is a thread here: https://www.drupal.org/node/1977118
I think you'll find something there.

Uganda

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: