Hello all,
I’ve been using Solspace’s add-ons on a few different project and truly love them. Great job, Solspace!
Recently I ran into an issue trying to get a user’s member photo. I have able to get the photo_filename, but photo_url is returning blank. I haven’t experienced this before I upgraded to 3.3.7 so I’m thinking that it might have something to do with that. Here is the code that I am using:
{exp:user:stats member_id="{author_id}" dynamic="off" member_only="no"}
<a class="seller-brand" href="{path='profiles/profile'}/{member_id}">
{exp:ce_img:single src="{photo_url}{photo_filename}" alt="{full_name}" crop="no" max_width="98" max_height="98" cache="yes" refresh="360"}
</a>
<a href="{path='profiles/profile}/{member_id}" class="seller-review">
<span class="icon icon-review"></span>
View Seller Reviews
</a>
{/exp:user:stats}
I know that it is getting into the loop as the links are going to the correct place, and after some testing I found that the photo_filename is coming through too, it’s just the photo_url that’s not.
So some information on my system, running EE 2.4.0 with User 3.3.7. Any help will be much appreciated.
Thanks,
Lucas
Hi Lucas,
Do you have a URL saved under the “URL to Photos Folder” setting in the Member preferences section of the CP (Members => Preferences)?
I tried outputting {photo_url} on EE 2.4 and User 3.3.7, and had no trouble getting the URL displayed. Have you tried {photo_url} on its own, outside of the {exp:ce_img} tag?
Hi Nicolas,
Thank you for your quick response. Unfortunately, the answer is yes to both of your questions. The URL to Photos Folder is set and correct, and I have tried outputting {photo_url} on it’s own but it still comes through blank.
Any other idea?
Thank you,
Lucas
Hm, I can’t think of anything else to check.
Can you PM me with a login account so I can have a direct look? Please tell me what template I should be looking at. Thanks
This has been sent.
I think it’s fixed now ![]()
I tried {photo_url} on your page directly, not within ce_img, and the URL showed up correctly.
Then I realized that {photo_url} contains the filename, so {photo_filename} isn’t necessary! I’m seeing an image now, let me know if you do as well
Thanks Nicolas! I am seeing it, but only when I log out. If I view it while logged in as either the user or the site super admin I don’t see it. I have added this line (photo = {photo_url}) above all of the ce_img stuff, so if you take a look again you can see that there.
I’m logged in as a Super Admin and can see an image. Have you cleared your browser and EE cache?
On a possibly separate note, the {exp:user:stats} is inside a {exp:channel:entries} tag, is that right?
It seems that User is considering member_id=”{author_id}” as the member_id of the author of the entry currently being displayed. Is that what you want, or do you want the to display stats of the currently logged in user?
So strange. I’ve cleared all my browser cache and the EE cache, but I’m still not seeing the image.
Thank you for pointing this out. I do want the information of the channel author to be displayed, so I think that it is correct. Do you have a suggestion of maybe a better way of approaching this? Though I’ve done a few sites in EE, I’m always open to new/better ways of doing stuff
.
Thanks,
Lucas
I’ve been looking around your setup, and I noticed that when you log in (I logged in as you since I’m a Super Admin), you don’t see {photo_url}, whereas when I log in I see {photo_url} even though I’m also a Super Admin. This is very mysterious.
I guess you could go to the bottom of this by trying out {exp:user:stats} on a fresh and separate blank template and using member_id=“4” (the member from which you’re trying to display the {photo_url}), to see if the variable renders when logged in as yourself, me, or when logged out. ![]()
EDIT: I also turned on the Output profiler, to see if queries are different under me or you, but saw nothing out of the ordinary.
Thank you again! I had noticed the Output profiler being on, and figured it was you
.
I will try out your suggestions tomorrow and give you and update as it goes.
Thanks,
Lucas
Good Morning Nicolas,
So I have tried what you suggested (http://staging.greenstreamline.com/profiles/test_profile) and as you can see here, it is working as expected. After seeing this, I went to the products/item page that we were testing on yesterday and replaced member_id=”{author_id}” to member_id=“4” and I am still not seeing the photo_url coming through. I did login as the user that I set up for you and I could see it then, but not with the actual author of the entry or my super admin account. So confusing
.
Do you think that it could be that the {exp:user:stats} tag is inside of the {exp:channel:entries} tag? I’m really confused as to what is going on here, so any suggestion would be great.
Thanks,
Lucas
Hi Lucas,
I tried a hard-coded value as well, and although I could see member_id 4’s image, once logged in under your account I still couldn’t see this. Very odd indeed.
A solution that might be worth trying, though, would be to place this {exp:user:stats} code in an embed. Your template is fairly complex, so there might be some variable clash or the like going on when the tag is not embedded.
Hey Nicolas,
Cool. I’ve moved this out into an embed and everything is working as expected. Just out of curiosity, I heard somewhere that using embeds can slow down page loads, is this true? I’m not to worried here, but there are places that I have purposely not used embeds for the sake of speed.
Thank you so much for all of your help. You can close this out now.
Thanks,
Lucas
Great! I guess there was a parsing/variable clash issue somewhere. ![]()
Indeed, embeds are not recommended for performance reasons, but sometimes you have no choice to avoid parsing issues, etc. Alternatively, you could use our very own Template Morsels module, which works similar to embeds, but without the embedding overhead, leading to much better performance ![]()
Since the issue is resolved, I’ll close the thread, but feel free to post again if you have other questions!