Default avatar

I want to have a default avatar if the user doesn’t have one selected, i have tried several different things to no avail …

Something like this…Although it is not finished…

Replace

<img src="<?php echo SITE_URL.AVATAR_PATH.'/'.$pilotcode.'.png';?>" alt="No Avatar" />

 

with

<?php
		if(!file_exists(SITE_ROOT.AVATAR_PATH.'/'.$pilotcode.'.png'))
		{
			echo 'No avatar';
		}
		else
		{
			echo '<img src="'.SITE_URL.AVATAR_PATH.'/'.$pilotcode.'.png'.'" alt="No Avatar" /> ';
		}
		?>

Should be able to see how that works..

I changed it but still, how is it going to find to my defualt picture

you put your image in this line:   

echo ‘<img src="’.SITE_URL.YOUR_IMAGE_GOES_HERE.‘/’.$pilotcode.‘.png’.'" alt=“No Avatar” /> ';

sustituye http://fac-virtual.com/noavtar.png for url your image.

excuse my english

<?php
		if(!file_exists(SITE_ROOT.AVATAR_PATH.'/'.$pilotcode.'.png'))
		{
			echo '<img src="http://fac-virtual.com/noavatar.png" alt="No Avatar" />';
		}
		else
		{
			echo '<img src="'.SITE_URL.AVATAR_PATH.'/'.$pilotcode.'.png'.'" alt="No Avatar" /> ';
		}
		?>

I did what you told me but it didnt work

That is wrong captain:

<?php

        if(!file_exists(SITE_ROOT.AVATAR_PATH.‘/’.$pilotcode.‘.png’))

        {

            echo ‘No avatar’;

        }

        else

        {

            echo ‘<img src="’.SITE_URL.[glow=red,2,300]THIS IS WHERE YOUR IMAGE GOES[/glow].‘/’.$pilotcode.‘.png’.'" alt=“No Avatar” /> ';

        }

        ?>

I did what you told me but still not working, do i put the folder name and image or the full link or only image

You shouldn’t change that else { } statement, that’ll break. I think you meant that in the first one

Can you please give me the full Code that i need to replace in The Profile.tpl

It should be the code that novamix posted

Hi guys,

My code looks like this:

<?php
        if(!file_exists(SITE_ROOT.AVATAR_PATH.'/'.$pilotcode.'.png'))
        {
            echo '<img src="'.SITE_URL.AVATAR_PATH.'/pilotavatar.png" alt="No Avatar" />';
        }
        else
        {
            echo '<img src="'.SITE_URL.AVATAR_PATH.'/'.$pilotcode.'.png'.'" alt="No Avatar" /> ';
        }
        ?>

It displays the pilotavatar.png for the pilots without avatar, but below the missing image (red X) is still there.

What to do?

Take a look at the source and see what that URL comes out to

The output HTML looks like this:

<td valign="top" align="center">
<img src="http://www.ivao.ro/blueair/lib/avatars/JOR001.png"/>
<br/>
<br/>
<img src=""/>
</td>

What about for someone who doesn’t have an avatar?

This one did not upload any avatar and that’s why the default is showed.

<td valign="top" align="center">
<img alt="No Avatar" src="http://www.ivao.ro/blueair/lib/avatars/pilotavatar.png"/>
<br/>
<br/>
<img alt="" src=""/>
</td>

I didn’t see any error, but one of  my testers is using Iexplorer and he gets the red X below the avatars.

Well, there’s a blank <img alt=“” src=“”/> sitting there - what’s the full code for that, which you put into the template?

I did not alter the template. Same thing appears with “Crystal”.

You have to modify the template with what Roger posted, off the top of my head.

I changed in the pilot_public_profile.tpl

this:

<img src="<?php echo SITE_URL.AVATAR_PATH.'/'.$pilotcode.'.png';?>" alt="No Avatar" />

with this:

<?php
        if(!file_exists(SITE_ROOT.AVATAR_PATH.'/'.$pilotcode.'.png'))
        {
            echo '<img src="'.SITE_URL.AVATAR_PATH.'/pilotavatar.png" alt="No Avatar" />';
        }
        else
        {
            echo '<img src="'.SITE_URL.AVATAR_PATH.'/'.$pilotcode.'.png'.'" alt="No Avatar" /> ';
        }
        ?>

Donno where is the bug hidden.