av8rmike: Neo from Matrix, text: I know S2 (I know s2)
[personal profile] av8rmike
(Probably only of interest to [livejournal.com profile] camomiletea, [livejournal.com profile] scaryjeff, [livejournal.com profile] afuna, or anyone else in Styles support)

There was a recent request about substituting a user's default userpic for the one they'd selected for a particular post. We figured it was possible through S2, but we don't give that level of detail through Support. I found out something interesting while trying to figure it out for myself...

The S2 Core stores the entry user icon in $userpic, an Image member of the EntryLite class (usually called in print_entry() like $e.userpic.url). A user's default icon is stored in the User class, which is derived from UserLite. EntryLite class also contains a UserLite object called $poster, the author of the entry. Since Expressive (unlike other layouts) passes the EntryLite object into print_entry() directly, I thought I could get away with something like this:

var User u = $e.poster as User;
var Image def_pic = $u.default_pic;
var string userpic = ($showuserpic and defined $e.userpic) ? ($def_pic + "<br />") : "";
It compiles, but it doesn't work, it just comes up with an empty string. Even trying to isolate the Image members doesn't work:

var string pic_url = """<img src="$def_pic.url" alt="$e.userpic.alttext" title="$e.poster.name" height="$def_pic.height" width="$def_pic.width" />""";

Maybe [livejournal.com profile] afuna or someone who knows the back-end better knows why, but I guess you can't re-cast a UserLite object like you can an EntryLite (print_entry() in Expressive re-casts the EntryLite argument into a Comment or Entry object, depending on the type). Even if the preceding were possible, this approach wouldn't work in most layers anyway, because they call print_entry() on Entry objects.

Date: 2008-11-10 04:27 pm (UTC)
From: [identity profile] martygreene.livejournal.com
I certainly don't know the answer (you know as well as I do that I'm not nearly as advanced with S2 as you are, heh) but I do have to ask... how is this even an S2 isssue? Wouldn't edit post and changing the icon in the edit screen accomplish the same thing, or am I totally missing something here (entirely possible due to cold+cold meds)?

Date: 2008-11-10 05:07 pm (UTC)
From: [identity profile] av8rmike.livejournal.com
Well, this post was referring to two Support requests from one user who was convinced there was an option or some way to keep her from seeing her friends' "adult" icons (or conversely, a way to keep them from seeing her icons).
In other words, she (or her friends) could post with a certain icon, but through some magic, the offending icon would be replaced with their default. Unfortunately, there ain't no such thing as magic.

Date: 2008-11-10 05:14 pm (UTC)
From: [identity profile] martygreene.livejournal.com
oh g-d if that existed though I would be so happy. There are a few people I'm friends with but can't read their journals but for icons which trigger my phobias.

alas, as you said, no magic.

Date: 2008-11-10 05:20 pm (UTC)
From: [identity profile] tidesong.livejournal.com
I'll show you a back-end all right....

Date: 2008-11-10 05:31 pm (UTC)
From: [identity profile] av8rmike.livejournal.com
This WAS a family post, until now... ;)

Date: 2008-11-10 05:50 pm (UTC)
From: [identity profile] tidesong.livejournal.com
Is there a way in S2 to not see a specific userpic someone has? Because there are some that some people just shouldn't use when replying to me.... ;)

*blinks innocently*

Date: 2008-11-10 06:20 pm (UTC)
From: [identity profile] av8rmike.livejournal.com
Due to the volume of requests, Support volunteers cannot provide detailed customization assistance. If you need more help with this, you may wish to look for a community dedicated to customization assistance. The following FAQ explains how to find a relevant community: http://www.livejournal.com/support/faqbrowse.bml?faqid=85.

Date: 2008-11-10 09:13 pm (UTC)

Date: 2008-11-10 06:39 pm (UTC)
From: [identity profile] lollobrigida.livejournal.com
I don't understand anything that was in this post except : There was a recent request

Date: 2008-11-10 06:46 pm (UTC)
From: [identity profile] av8rmike.livejournal.com
I do explain it a little better in my reply to [livejournal.com profile] martygreene above...

Date: 2008-11-10 07:02 pm (UTC)
From: [identity profile] lollobrigida.livejournal.com
So I gathered, and I was thinking the same thing as them. It's alright cause it's not really anything I care about. Goofy people with offensive icons that actually care if people find them offensive.

Date: 2008-11-12 01:20 am (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
The difference is that the EntryLite object is used for convenience (to contain common properties), and always has a backing Entry or Comment with the additional fields populated. It's just a matter of figuring out what subclass you're in now.

The UserLite object is used for efficiency, and if it's used explicitly instead of User, will not be populated with the additional data.

Not sure if there's anything you can get that data from.

Date: 2008-11-12 12:01 pm (UTC)
From: [identity profile] av8rmike.livejournal.com
I'm not sure I understand all that, but it doesn't really matter. If it's not possible, it's not possible, and I answered the request on Monday. Thank you, though.

I realized recently that the requester may have been referring to the "Use Shared User Icons" option on layouts, but I discovered that it only applies to community posts on one's Friends Page. Looking at FriendsPage.pm, do you think it's possible to extend to personal posts, and is that a worthwhile suggestion to submit?

Date: 2008-11-12 02:40 pm (UTC)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
From: [personal profile] afuna
I haven't looked at the code -- but the answer is going to be "Yes" :-)

Profile

av8rmike: Futurama's Bender in Jeffries tube, text: I'm done reconfoobling the energymotron (Default)
av8rmike

November 2010

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 2930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 17th, 2025 11:19 pm
Powered by Dreamwidth Studios