Avatar source code?

Started by Alex Stanford, December 12, 2009, 06:40:33 PM

Previous topic - Next topic

Alex Stanford

Hello everyone,

In index.template.php of the SMF Default theme on 2.0 RC2 you will find something like this:

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
if (!empty($context['user']['avatar']))
echo '
        ', $context['user']['avatar']['image'];


Which seems to generate the following markup:

<img src="http://ryanreese.net/alextestfolder/smfrewrite/avatars/Actors/Brad_Pitt.jpg" alt="" class="avatar" border="0" />

Note that this is already slightly modified code.

I'm trying to edit the markup that is produced when you call that first code block.  Where can I find the code I'm calling?

Thanks in advance,
Alex

Arantor

Depends what you want to do with it, really.

It's generated from loadMemberContext in Load.php.

Alex Stanford

My goal is to remove border="0" from the markup and implement it via CSS.

I found the code generating, and removed all three references to border="0" but it still remains.  How can I get rid of this?  If I can lose it globally, that would even be better.

Alex

Alex Stanford


Arantor

You know, you didn't have to create a whole new thread, you could have used this one?

* Arantor debates actually merging this one.

Alex Stanford

Quote from: Arantor on December 13, 2009, 04:52:42 AM
You know, you didn't have to create a whole new thread, you could have used this one?

* Arantor debates actually merging this one.


Arantor: I realize that, but I don't think this thread was created on the right basis.  Feel free to delete or merge this thread.

Arantor

Ultimately I'd still answer it either way, and topics can and do change over their course.

I just considered merging but ultimately you had 6 questions which individually might have been better served in their own topics.

Alex Stanford

Quote from: Arantor on December 13, 2009, 10:51:58 AM
Ultimately I'd still answer it either way, and topics can and do change over their course.

I just considered merging but ultimately you had 6 questions which individually might have been better served in their own topics.


Arantor,

I consided using a topic for each, but felt it was overkill as those 6 issues are only the first few of many.

Do you think I should have used a thread for each?

DavidCT

What about a fark-fix?

index.template.php, somewhere...before output...

$context['user']['avatar']['image'] = str_replace(' border="0"', '', $context['user']['avatar']['image']);

Alex Stanford

Quote from: DavidCT on December 13, 2009, 12:19:06 PM
What about a fark-fix?

index.template.php, somewhere...before output...

$context['user']['avatar']['image'] = str_replace(' border="0"', '', $context['user']['avatar']['image']);

I suppose something like that might work, but it's not my style.  The entire goal of my project is to minimalize the code and markup - not create bloat!  :)  Thanks for the post, though.

Joshua Dickerson

Just go in to Load.php and change it. You don't even have to. The array has everything you should need. If it doesn't, it should. So make a post saying what isn't there that should be.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Alex Stanford

Quote from: groundup on December 14, 2009, 02:21:02 PM
Just go in to Load.php and change it. You don't even have to. The array has everything you should need. If it doesn't, it should. So make a post saying what isn't there that should be.

I do not know how to:

1. Change it in Load.php
2. Change it using the arrays...

I need more specific explanations of this in order to understand.

Thanks groundup.

Joshua Dickerson

Hopefully by the final release, the border="0" will be gone everywhere.

Here's the block in Load.php.
'avatar' => array(
'name' => $profile['avatar'],
'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
),
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Alex Stanford

#13
Quote from: groundup on December 14, 2009, 03:35:35 PM
Hopefully by the final release, the border="0" will be gone everywhere.

Here's the block in Load.php.
     'avatar' => array(
         'name' => $profile['avatar'],
         'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" border="0" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" border="0" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" border="0" />'),
         'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
         'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
      ),


Here is what I have, please explain how I can remove the border="0" using the following code block:

      'avatar' => array(
         'name' => $profile['avatar'],
         'image' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? '<img src="' . (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) . '" alt="" class="avatar" />' : '') : (stristr($profile['avatar'], 'http://') ? '<img src="' . $profile['avatar'] . '"' . $avatar_width . $avatar_height . ' alt="" class="avatar" />' : '<img src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($profile['avatar']) . '" alt="" class="avatar" />'),
         'href' => $profile['avatar'] == '' ? ($profile['id_attach'] > 0 ? (empty($profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $profile['filename']) : '') : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar']),
         'url' => $profile['avatar'] == '' ? '' : (stristr($profile['avatar'], 'http://') ? $profile['avatar'] : $modSettings['avatar_url'] . '/' . $profile['avatar'])
      ),


I believe I have already removed it, but it's still present on my forum.

Arantor

Where, exactly is that code block? Is it the one inside the loadMemberContext function?

Alex Stanford

Quote from: Arantor on December 14, 2009, 05:23:54 PM
Where, exactly is that code block? Is it the one inside the loadMemberContext function?


I have no idea, I found it by using this sequence in my editor:

Ctrl + F
"avatar"
enter
(repeat last step [enter] until found)

lol

In other words, I used the find function in my editor to search for "avatar" within the Load.php file.

Arantor

Yes, I realise that Ctrl-F is the find function and has been for well over a decade on most platforms.

How about trying lateral thinking and using that for border="0" ? If you have a half way decent editor it can apply that search in all files.

* Arantor leaves the thread before saying something more he will regret.

Joshua Dickerson

Alex, if you are going to rewrite SMF, you are going to have to learn some PHP. If it's a local thing you are trying to do, just make the changes in Load.php. Find and replace " border="0"" then "border="0" " and then "border="0"" with blank strings. I don't know what editor you're using, but all the ones that I've used allow for find/replace in a directory.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Alex Stanford

#18
Quote from: groundup on December 14, 2009, 07:17:45 PM
Alex, if you are going to rewrite SMF, you are going to have to learn some PHP. If it's a local thing you are trying to do, just make the changes in Load.php. Find and replace " border="0"" then "border="0" " and then "border="0"" with blank strings. I don't know what editor you're using, but all the ones that I've used allow for find/replace in a directory.

I have used the Find and Replace function to remove every instance of border="0" within the Load.php file - yet when I visit my forum, the attribute remains active.

Does this need to be done on every file in the Sources directory?

Joshua Dickerson

Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Advertisement: